示例#1
0
 public function onGet()
 {
     parent::onGet();
     $links = [];
     $apiPath = $this->reverseRouter->getDispatchUrl();
     if ($apiPath !== null) {
         $links[] = new Object(['rel' => 'api', 'href' => $apiPath]);
     }
     $routingPath = $this->reverseRouter->getUrl('PSX\\Controller\\Tool\\RoutingController');
     if ($routingPath !== null) {
         $links[] = new Object(['rel' => 'routing', 'href' => $routingPath]);
     }
     $commandPath = $this->reverseRouter->getUrl('PSX\\Controller\\Tool\\CommandController');
     if ($commandPath !== null) {
         $links[] = new Object(['rel' => 'command', 'href' => $commandPath]);
     }
     $documentationPath = $this->reverseRouter->getUrl('PSX\\Controller\\Tool\\DocumentationController::doIndex');
     if ($documentationPath !== null) {
         $links[] = new Object(['rel' => 'documentation', 'href' => $documentationPath]);
     }
     $ramlGeneratorPath = $this->reverseRouter->getUrl('PSX\\Controller\\Tool\\RamlGeneratorController', ['{version}', '{path}']);
     if ($ramlGeneratorPath !== null) {
         $links[] = new Object(['rel' => 'raml', 'href' => $ramlGeneratorPath]);
     }
     $wsdlGeneratorPath = $this->reverseRouter->getUrl('PSX\\Controller\\Tool\\WsdlGeneratorController', ['{version}', '{path}']);
     if ($wsdlGeneratorPath !== null) {
         $links[] = new Object(['rel' => 'wsdl', 'href' => $wsdlGeneratorPath]);
     }
     $swaggerGeneratorPath = $this->reverseRouter->getUrl('PSX\\Controller\\Tool\\SwaggerGeneratorController::doDetail', ['{version}', '{path}']);
     if ($swaggerGeneratorPath !== null) {
         $links[] = new Object(['rel' => 'swagger', 'href' => $swaggerGeneratorPath]);
     }
     $this->setBody(['links' => $links]);
 }
示例#2
0
 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());
 }
示例#3
0
 public function onPost()
 {
     parent::onPost();
     $commandClass = $this->getParameter('command');
     $parameters = $this->getBody();
     $parameters = !empty($parameters) ? $parameters : array();
     if (!empty($commandClass)) {
         $stream = fopen('php://memory', 'r+');
         $this->logger->pushHandler(new StreamHandler($stream, Logger::DEBUG));
         $this->executor->run(new ParameterParser\Map($commandClass, $parameters));
         $output = stream_get_contents($stream, -1, 0);
         $this->logger->popHandler();
         $this->setBody(array('output' => $output));
     } else {
         throw new \Exception('Command not available');
     }
 }
示例#4
0
 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);
     }
 }
示例#5
0
 public function onGet()
 {
     parent::onGet();
     $this->setBody(array('routings' => $this->getRoutings()));
 }
示例#6
0
 public function onLoad()
 {
     parent::onLoad();
     $this->setBody(array('message' => 'This is the default controller of PSX', 'url' => 'http://phpsx.org'));
 }