fix for Template and Route annotatoin

This commit is contained in:
Tomas Votruba 2019-10-24 00:34:49 +02:00
parent da47c3145f
commit de875ab00d
4 changed files with 41 additions and 2 deletions

View File

@ -40,18 +40,42 @@ final class SymfonyRouteTagValueNode extends AbstractTagValueNode
*/
private $isPathExplicit = true;
/**
* @var mixed[]
*/
private $options = [];
/**
* @var mixed[]
*/
private $defaults = [];
/**
* @var mixed[]
*/
private $requirements = [];
/**
* @param string[] $methods
* @param string[] $options
* @param string[] $defaults
* @param string[] $requirements
*/
public function __construct(
string $path,
?string $name = null,
array $methods = [],
array $options = [],
array $defaults = [],
array $requirements = [],
?string $originalContent = null
) {
$this->path = $path;
$this->name = $name;
$this->methods = $methods;
$this->options = $options;
$this->defaults = $defaults;
$this->requirements = $requirements;
if ($originalContent !== null) {
$this->isPathExplicit = (bool) Strings::contains($originalContent, 'path=');
@ -80,6 +104,18 @@ final class SymfonyRouteTagValueNode extends AbstractTagValueNode
$contentItems['methods'] = $this->printArrayItem($this->methods, 'methods');
}
if ($this->options) {
$contentItems['options'] = $this->printArrayItem($this->options, 'options');
}
if ($this->defaults) {
$contentItems['defaults'] = $this->printArrayItem($this->defaults, 'defaults');
}
if ($this->requirements) {
$contentItems['requirements'] = $this->printArrayItem($this->requirements, 'requirements');
}
return $this->printContentItems($contentItems);
}

View File

@ -40,6 +40,9 @@ final class SymfonyRoutePhpDocNodeFactory extends AbstractPhpDocNodeFactory
$route->getPath(),
$route->getName(),
$route->getMethods(),
$route->getOptions(),
$route->getDefaults(),
$route->getRequirements(),
$annotationContent
);
}

View File

@ -8,7 +8,7 @@ use Symfony\Component\Routing\Annotation\Route;
class WithRouteOptions
{
/**
* @Route("/{category}", name="report_overview", defaults={"category" = null}, requirements={"category" = "\d+"})
* @Route("/{category}", name="report_overview", defaults={"category":null}, requirements={"category":"\d+"})
* @Template("PAPPReportBundle:Report:report_list.html.twig")
*/
public function index($category = null)
@ -31,7 +31,7 @@ use Symfony\Component\Routing\Annotation\Route;
class WithRouteOptions
{
/**
* @Route("/{category}", name="report_overview", defaults={"category" = null}, requirements={"category" = "\d+"})
* @Route("/{category}", name="report_overview", defaults={"category":null}, requirements={"category":"\d+"})
*/
public function index($category = null)
{