public function onLoad() { parent::onLoad(); $doc = $this->resourceListing->getDocumentation($this->context->get(Context::KEY_PATH)); if (!$doc instanceof DocumentationInterface) { throw new RuntimeException('No documentation available'); } $this->version = $this->getVersion($doc); $this->resource = $this->getResource($doc, $this->version); if (!$this->resource->hasMethod($this->getMethod())) { throw new StatusCode\MethodNotAllowedException('Method is not allowed', $this->resource->getAllowedMethods()); } $this->pathParameters = $this->schemaAssimilator->assimilate($this->resource->getPathParameters(), $this->uriFragments); $this->queryParameters = $this->schemaAssimilator->assimilate($this->resource->getMethod($this->getMethod())->getQueryParameters(), $this->request->getUri()->getParameters()); }
public function onLoad() { parent::onLoad(); try { $error = $this->getParameter('error'); // error detection if (!empty($error)) { AuthorizationAbstract::throwErrorException($this->request->getUri()->getParameters()); } $code = $this->getParameter('code'); $state = $this->getParameter('state'); if (empty($code)) { throw new Exception('Code not available'); } $redirectUri = ''; // get access token $accessToken = $this->getAuthorizationCode($code, $state)->getAccessToken($code, $redirectUri); $this->onAccessToken($accessToken); } catch (ErrorExceptionAbstract $e) { $this->onError($e); } }
public function onLoad() { parent::onLoad(); $this->setBody(array('message' => 'This is the default controller of PSX', 'url' => 'http://phpsx.org')); }