getAnnotations example

try {
            $globals = $this->getGlobals($class);
            $collection = new RouteCollection();
            $collection->addResource(new FileResource($class->getFileName()));
            if ($globals['env'] && $this->env !== $globals['env']) {
                return $collection;
            }
            $fqcnAlias = false;
            foreach ($class->getMethods() as $method) {
                $this->defaultRouteIndex = 0;
                $routeNamesBefore = array_keys($collection->all());
                foreach ($this->getAnnotations($method) as $annot) {
                    $this->addRoute($collection$annot$globals$class$method);
                    if ('__invoke' === $method->name) {
                        $fqcnAlias = true;
                    }
                }

                if (1 === $collection->count() - \count($routeNamesBefore)) {
                    $newRouteName = current(array_diff(array_keys($collection->all())$routeNamesBefore));
                    $collection->addAlias(sprintf('%s::%s', $class->name, $method->name)$newRouteName);
                }
            }
            
$globals = $this->getGlobals($class);

        $collection = new RouteCollection();
        $collection->addResource(new FileResource($class->getFileName()));

        if ($globals['env'] && $this->env !== $globals['env']) {
            return $collection;
        }

        foreach ($class->getMethods() as $method) {
            $this->defaultRouteIndex = 0;
            foreach ($this->getAnnotations($method) as $annot) {
                $this->addRoute($collection$annot$globals$class$method);
            }
        }

        if (0 === $collection->count() && $class->hasMethod('__invoke')) {
            $globals = $this->resetGlobals();
            foreach ($this->getAnnotations($class) as $annot) {
                $this->addRoute($collection$annot$globals$class$class->getMethod('__invoke'));
            }
        }

        
public function __construct(Reader $reader = null)
    {
        $this->reader = $reader;
    }

    public function loadClassMetadata(ClassMetadata $metadata): bool
    {
        $reflClass = $metadata->getReflectionClass();
        $className = $reflClass->name;
        $success = false;

        foreach ($this->getAnnotations($reflClass) as $constraint) {
            if ($constraint instanceof GroupSequence) {
                $metadata->setGroupSequence($constraint->groups);
            } elseif ($constraint instanceof GroupSequenceProvider) {
                $metadata->setGroupSequenceProvider(true);
            } elseif ($constraint instanceof Constraint) {
                $metadata->addConstraint($constraint);
            }

            $success = true;
        }

        
public function __construct(Reader $reader = null)
    {
        $this->reader = $reader;
    }

    public function loadClassMetadata(ClassMetadata $metadata): bool
    {
        $reflClass = $metadata->getReflectionClass();
        $className = $reflClass->name;
        $success = false;

        foreach ($this->getAnnotations($reflClass) as $constraint) {
            if ($constraint instanceof GroupSequence) {
                $metadata->setGroupSequence($constraint->groups);
            } elseif ($constraint instanceof GroupSequenceProvider) {
                $metadata->setGroupSequenceProvider(true);
            } elseif ($constraint instanceof Constraint) {
                $metadata->addConstraint($constraint);
            }

            $success = true;
        }

        
Home | Imprint | This part of the site doesn't use cookies.