コード例 #1
0
 /**
  * @dataProvider dataTestApiDeclaration
  */
 public function testApiDeclaration($resource, $expected)
 {
     set_error_handler(array($this, 'handleDeprecation'));
     $data = $this->extractor->all();
     restore_error_handler();
     $actual = $this->formatter->format($data, $resource);
     $this->assertEquals($expected, $actual);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
         return;
     }
     $request = $event->getRequest();
     if (!$request->query->has($this->parameter)) {
         return;
     }
     $controller = $request->attributes->get('_controller');
     $route = $request->attributes->get('_route');
     if (null !== ($annotation = $this->extractor->get($controller, $route))) {
         $result = $this->formatter->formatOne($annotation);
         $event->setResponse(new Response($result, 200, array('Content-Type' => 'text/html')));
     }
 }
コード例 #3
0
ファイル: Extractor.php プロジェクト: blast007/bzion
 /**
  * Returns the ReflectionMethod for the given controller string.
  *
  * @param  \ReflectionMethod|string $controller
  * @return \ReflectionMethod|null
  */
 public function getReflectionMethod($controller)
 {
     if ($controller instanceof \ReflectionMethod) {
         return $controller;
     } else {
         return parent::getReflectionMethod($controller);
     }
 }
コード例 #4
0
 public function all($view = ApiDoc::DEFAULT_VIEW)
 {
     if ($this->cache->isFresh() === false) {
         $resources = array();
         foreach ($this->getRoutes() as $route) {
             if (null !== ($method = $this->getReflectionMethod($route->getDefault('_controller'))) && null !== ($annotation = $this->reader->getMethodAnnotation($method, self::ANNOTATION_CLASS))) {
                 $file = $method->getDeclaringClass()->getFileName();
                 $resources[] = new FileResource($file);
             }
         }
         $resources = array_merge($resources, $this->router->getRouteCollection()->getResources());
         $data = parent::all($view);
         $this->cache->write(serialize($data), $resources);
         return $data;
     }
     return unserialize(file_get_contents($this->cacheFile));
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function getRoutes()
 {
     return RouteCollectionUtil::filterHidden(parent::getRoutes());
 }
コード例 #6
0
 protected function normalizeClassParameter($input, DunglasResource $resource = null)
 {
     $dataResponse = [];
     if (in_array(strtolower($this->versionApi), $this->nelmioDocStandardVersion)) {
         return parent::normalizeClassParameter($input);
     }
     $dataResponse = parent::normalizeClassParameter($input);
     $dataResponse['groups'] = $resource->getValidationGroups();
     return $dataResponse;
 }