Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function handle(ApiDoc $annotation, array $annotations, Route $route, \ReflectionMethod $method)
 {
     if (!$route->getOption('old_options')) {
         return;
     }
     $annotation->setDeprecated(true);
     $annotation->setDocumentation($annotation->getDocumentation() . "\n\nDeprecated since v1.8. Will be removed in v2.0");
 }
 /**
  * {@inheritdoc}
  */
 public function handle(ApiDoc $annotation, array $annotations, Route $route, \ReflectionMethod $method)
 {
     if ($route->getOption('group') !== DictionaryEntityRouteOptionsResolver::ROUTE_GROUP) {
         return;
     }
     $pluralAlias = $route->getDefault(DictionaryEntityRouteOptionsResolver::ENTITY_ATTRIBUTE);
     if (!$pluralAlias) {
         return;
     }
     $className = $this->entityAliasResolver->getClassByPluralAlias($pluralAlias);
     $pluralName = $this->entityClassNameProvider->getEntityClassPluralName($className);
     if ($pluralName) {
         $annotation->setDescription(strtr(static::DESCRIPTION_TEMPLATE, ['{plural_name}' => $pluralName]));
         $annotation->setDocumentation(strtr(static::DOCUMENTATION_TEMPLATE, ['{plural_name}' => $pluralName]));
     } else {
         $annotation->setDescription(strtr(static::FALLBACK_DESCRIPTION_TEMPLATE, ['{class}' => $className]));
         $annotation->setDocumentation(strtr(static::FALLBACK_DOCUMENTATION_TEMPLATE, ['{class}' => $className]));
     }
 }
Пример #3
0
 /**
  * @param ApiDoc      $annotation
  * @param string      $action
  * @param array       $config
  * @param string|null $entityClass
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function setDescription(ApiDoc $annotation, $action, array $config, $entityClass = null)
 {
     $templates = $this->templates[$action];
     $entityName = false;
     // set description
     $description = null;
     if (!empty($config[$templates['description_key']])) {
         $description = $config[$templates['description_key']];
     }
     if ($description) {
         $description = strtr($templates['description'], ['{name}' => $description]);
     } elseif ($entityClass) {
         $entityName = $this->entityClassNameProvider->{$templates['get_name_method']}($entityClass);
         $description = $entityName ? strtr($templates['description'], ['{name}' => $entityName]) : strtr($templates['fallback_description'], ['{class}' => $entityClass]);
     }
     if ($description) {
         $annotation->setDescription($description);
     }
     // set documentation
     $documentation = null;
     if (!empty($config[$templates['documentation_key']])) {
         $documentation = $config[$templates['documentation_key']];
     }
     if (!$documentation && $entityClass) {
         if (false === $entityName) {
             $documentation = $this->entityClassNameProvider->{$templates['get_name_method']}($entityClass);
         }
         if ($entityName) {
             $documentation = $entityName;
         }
     }
     if ($documentation) {
         $annotation->setDocumentation($documentation);
     }
 }