oauth2-server-php
oauth2-server-php copied to clipboard
Request object not compatible with Yii2 request interface
Since version Yii2 v. 2.0.36 the base controller class have these directives inside the init method:
public function init()
{
parent::init();
$this->request = Instance::ensure($this->request, Request::className());
$this->response = Instance::ensure($this->response, Response::className());
}
So any code in downstream classes that call parent::init() before their own installation will receive an error. This means the following init logic no longer works:
$request = OAuth2\Request::createFromGlobals();
Yii2 is also not PSR compliant so these is not possible:
// use HttpFoundation Requests instead, for Symfony / Twig / Laravel 4 / Drupal 8 / etc!
$symfony_request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
$request = OAuth2\HttpFoundationBridge\Request::createFromRequest($symfony_request)
Is there anything I can do? I can avoid the error by not calling parent::init() in the child classes but this is something of anti-pattern.
You could make your own bridge, similar to the HttpFoundationBridge for Yii requests.