Registra os serviços do pacote.

@param Service             $annotation
@param \ReflectionClass    $reflectionClass
@param PackServiceProvider $pack
503598
public function resolve($annotation, $reflectionClass, $pack)
    {
        $app = $this->app;

        $snakeClass = implode('_',preg_split('/(?=[A-Z])/', $reflectionClass->getShortName(), -1, PREG_SPLIT_NO_EMPTY));
        $relativeNamespace = preg_replace('/'.$pack->getNameSpace().'/', '', $reflectionClass->getName(), 1);
        list($empty, $serviceDir, $serviceClass) = explode('\\', $relativeNamespace);
        $serviceKey = implode('.',[$pack->getPackName(),strtolower($serviceDir), strtolower($snakeClass)]);

        $class = $reflectionClass->getName();
        switch ($annotation->type) {
            case 'factory':
                $app[$serviceKey] = $app->factory(function () use ($class, $app, $pack) {
                    return new $class($app, $pack);
                });
            break;
            case 'shared':
                $app[$serviceKey] = function () use ($class, $app, $pack) {
                    return new $class($app, $pack);
                };
            break;
            case 'protected':
                $app[$serviceKey] = $app->protect(function () use ($class, $app, $pack) {
                    return new $class($app, $pack);
                });
            break;
        }

        $this->registerParameters($reflectionClass, $serviceKey);
    }
233868
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('Config');

        return new FormAnnotationBuilder(
            isset($config['form_annotation_builder'])
                ? $config['form_annotation_builder']
                : null
            );
    }
1321364
protected function loadReceiverProperties(\ReflectionClass $class)
    {
        $receiverPropertiesTypes = [];
        $properties = $class->getProperties();

        //Store receiver properties
        foreach ($properties as $property) {
            $annotations = $this->reader->getPropertyAnnotations($property);
            foreach ($annotations as $key => $annotationObj) {
                if ($annotationObj instanceof ReceiverPropertyAnnotation && !in_array($class, $receiverPropertiesTypes)) {
                    if (!$annotations[$key]->getTypes()) {
                        $message = $class->name.':$'.$property->name.'" field';

                        throw AnnotationException::requiredError('type', 'ReceiverProperty annotation', $message, 'array or string');
                    }
                    foreach ($annotations[$key]->getTypes() as $type) {
                        $receiverProperty = new ReceiverProperty();
                        $receiverProperty->setFieldName($property->name);
                        $receiverPropertiesTypes[$type][] = $receiverProperty;
                    }
                }
            }
        }

        //Set receiver properties as required if necessary
        foreach ($receiverPropertiesTypes as $type => $receiverProperties) {
            /* @var ReceiverProperty[] $receiverProperties */
            foreach ($receiverProperties as $receiverProperty) {
                $receiverPropertyName = $receiverProperty->getFieldName();
                $refProperty = $class->getProperty($receiverPropertyName);
                $annotations = $this->reader->getPropertyAnnotations($refProperty);

                foreach ($annotations as $key => $annotationObj) {
                    if ($annotationObj instanceof Column && $annotationObj->nullable === false) {
                        throw new Exception(sprintf(
                                'Property "%s" in class "%s" has a @ReceiverProperty annotation and by consequence must have "nullable=true" for ORM\Column annotation',
                                $refProperty->name,
                                $refProperty->class
                            ));
                    } elseif ($annotationObj instanceof NotBlank) {
                        throw new Exception(sprintf(
                                'Property "%s" in class "%s" has a @ReceiverProperty annotation and by consequence can not use NotBlank annotation',
                                $refProperty->name,
                                $refProperty->class
                            ));
                    } elseif ($annotationObj instanceof NotNull) {
                        throw new Exception(sprintf(
                                'Property "%s" in class "%s" has a @ReceiverProperty annotation and by consequence can not use NotNull annotation',
                                $refProperty->name,
                                $refProperty->class
                            ));
                    } elseif ($annotationObj instanceof ReceiverPropertyAnnotation && $annotationObj->isRequired()) {
                        $receiverProperty->setRequired(true);
                    }
                }
            }
        }

        return $receiverPropertiesTypes;
    }
1133515
public function addPrefix($annotation = null)
    {
        if (null === $this->ormPrefix) {
            $this->ormPrefix = '@'.$this->getConfig()->get(Formatter::CFG_ANNOTATION_PREFIX);
        }

        return $this->ormPrefix.($annotation ? $annotation : '');
    }
1234231
public function resolve($annotation, $reflectionClass, $pack)
    {
        $app = $this->app;


        $snakeClass = implode('_',preg_split('/(?=[A-Z])/', $reflectionClass->getShortName(), -1, PREG_SPLIT_NO_EMPTY));
        $controllerKey = implode('.',[$pack->getPackName(),'controller', strtolower($snakeClass)]);
        $controller = $reflectionClass->getShortName();

        $app[$controllerKey] = function () use ($app, $reflectionClass, $pack) {
            $class = $reflectionClass->getName();

            return new $class($app, $pack);
        };

        $$controller = $app['controllers_factory'];

        $this->registerControllerFilters($$controller, $controllerKey,  $annotation->filters);
        $this->registerRoutes($$controller, $controllerKey, $reflectionClass);

        $routePattern = ($annotation->mount != '')  ? $pack->getPackName().'/'.$annotation->mount : $pack->getPackName().'/'.strtolower($snakeClass);

        $this->app['controllers']->mount($routePattern, $$controller);

    }
116271
public function encerrar(
        Request $request,
        AtendimentoService $atendimentoService,
        TranslatorInterface $translator
    ) {
        $envelope = new Envelope();
        $data     = json_decode($request->getContent());

        $usuario = $this->getUser();
        $unidade = $usuario->getLotacao()->getUnidade();
        $atual   = $atendimentoService->atendimentoAndamento($usuario->getId(), $unidade);

        if (!$atual) {
            throw new Exception(
                $translator->trans('error.attendance.not_in_process', [], self::DOMAIN)
            );
        }

        $servicos   = explode(',', $data->servicos);
        $resolucao  = $data->resolucao;
        $observacao = $data->observacao;
        
        if (empty($servicos)) {
            throw new Exception(
                $translator->trans('error.attendance.no_service', [], self::DOMAIN)
            );
        }
        
        $em = $this->getDoctrine()->getManager();

        $novoUsuario = null;
        $servicoRedirecionado = null;
        
        if ($data->redirecionar) {
            $servicoRedirecionado = $em
                ->getRepository(Servico::class)
                ->find($data->novoServico);
            
            if (isset($data->novoUsuario)) {
                $novoUsuario = $em
                    ->getRepository(Usuario::class)
                    ->find($data->novoServico);
            }
        }
        
        if (in_array($resolucao, [ AtendimentoService::RESOLVIDO, AtendimentoService::PENDENTE ])) {
            $atual->setResolucao($resolucao);
        }
        
        if ($observacao) {
            $atual->setObservacao($observacao);
        }

        $atendimentoService->encerrar($atual, $unidade, $servicos, $servicoRedirecionado, $novoUsuario);

        return $this->json($envelope);
    }
1021348
public function registerPackage(string $sPackageClass, Closure $xClosure)
    {
        $this->aPackages[] = $sPackageClass;
        jaxon()->di()->set($sPackageClass, $xClosure);
    }
18132
public function readAnnotations($class, $pack)
    {
        $reader = new AnnotationReader();

        $reflectionClass = new \ReflectionClass($class);
        $classAnnotations = $reader->getClassAnnotations($reflectionClass);

        foreach ($classAnnotations as $annotation) {
            if ($annotation instanceof Controller) {
                $this->ctrlRegister->register($annotation, $reflectionClass, $pack);
            }
        }
    }
320940
protected function createValidatorInstanceFromAnnotation($validatorAnnotation)
    {
        return ValidatorBuilder::builder()
            ->withSpecification($validatorAnnotation->getValue())
            ->withClass($validatorAnnotation->getAssociatedClass())
            ->build();
    }
1242736
public function run(State $state, Logger $logger)
    {
        $annotationParser = new AnnotationParser(new DocParser());

        $logger->log(0, 'parse annotations');

        foreach ($state->config->getAnnotationNamespaces() as $namespace) {
            $annotationParser->registerNamespace($namespace);
        }

        foreach ($state->classes as $class) {
            try {
                $annotations = $annotationParser->parse($class);
            } catch (Exception $ex) {
                throw new AnnotationException(sprintf(
                    'failed to parse annotations of class %s. %s',
                    $class->name,
                    $ex->getMessage()
                ));
            }

            $logger->log(1, sprintf('of class %s', $class->name));

            foreach ($annotations as $annotation) {
                $logger->log(2, sprintf('found: <cyan>%s<reset>', get_class($annotation)));
                $state->annotations[] = $annotation;
            }
        }
    }
862028
private function convertClassAnnotationsToEntityClassMetadata(
        array $classAnnotations,
        ReflectionClass $reflectionClass,
        Mapping\ClassMetadata $parent
    ) {
        /** @var Annotation\Entity $entityAnnot */
        $entityAnnot   = $classAnnotations[Annotation\Entity::class];
        $classMetadata = new Mapping\ClassMetadata($reflectionClass->getName(), $parent);

        if ($entityAnnot->repositoryClass !== null) {
            $classMetadata->setCustomRepositoryClassName($entityAnnot->repositoryClass);
        }

        if ($entityAnnot->readOnly) {
            $classMetadata->asReadOnly();
        }

        // Evaluate @Table annotation
        if (isset($classAnnotations[Annotation\Table::class])) {
            /** @var Annotation\Table $tableAnnot */
            $tableAnnot = $classAnnotations[Annotation\Table::class];
            $table      = $this->convertTableAnnotationToTableMetadata($tableAnnot);

            $classMetadata->setTable($table);
        }

        // Evaluate @ChangeTrackingPolicy annotation
        if (isset($classAnnotations[Annotation\ChangeTrackingPolicy::class])) {
            /** @var Annotation\ChangeTrackingPolicy $changeTrackingAnnot */
            $changeTrackingAnnot = $classAnnotations[Annotation\ChangeTrackingPolicy::class];

            $classMetadata->setChangeTrackingPolicy(
                constant(sprintf('%s::%s', Mapping\ChangeTrackingPolicy::class, $changeTrackingAnnot->value))
            );
        }

        // Evaluate @EntityListeners annotation
        if (isset($classAnnotations[Annotation\EntityListeners::class])) {
            /** @var Annotation\EntityListeners $entityListenersAnnot */
            $entityListenersAnnot = $classAnnotations[Annotation\EntityListeners::class];

            foreach ($entityListenersAnnot->value as $listenerClassName) {
                if (! class_exists($listenerClassName)) {
                    throw Mapping\MappingException::entityListenerClassNotFound(
                        $listenerClassName,
                        $reflectionClass->getName()
                    );
                }

                $listenerClass = new ReflectionClass($listenerClassName);

                /** @var ReflectionMethod $method */
                foreach ($listenerClass->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
                    foreach ($this->getMethodCallbacks($method) as $callback) {
                        $classMetadata->addEntityListener($callback, $listenerClassName, $method->getName());
                    }
                }
            }
        }

        // Evaluate @HasLifecycleCallbacks annotation
        if (isset($classAnnotations[Annotation\HasLifecycleCallbacks::class])) {
            /** @var ReflectionMethod $method */
            foreach ($reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
                foreach ($this->getMethodCallbacks($method) as $callback) {
                    $classMetadata->addLifecycleCallback($method->getName(), $callback);
                }
            }
        }

        // Evaluate @InheritanceType annotation
        if (isset($classAnnotations[Annotation\InheritanceType::class])) {
            /** @var Annotation\InheritanceType $inheritanceTypeAnnot */
            $inheritanceTypeAnnot = $classAnnotations[Annotation\InheritanceType::class];

            $classMetadata->setInheritanceType(
                constant(sprintf('%s::%s', Mapping\InheritanceType::class, $inheritanceTypeAnnot->value))
            );

            if ($classMetadata->inheritanceType !== Mapping\InheritanceType::NONE) {
                $discriminatorColumn = new Mapping\DiscriminatorColumnMetadata();

                // Evaluate @DiscriminatorColumn annotation
                if (isset($classAnnotations[Annotation\DiscriminatorColumn::class])) {
                    /** @var Annotation\DiscriminatorColumn $discriminatorColumnAnnot */
                    $discriminatorColumnAnnot = $classAnnotations[Annotation\DiscriminatorColumn::class];

                    $discriminatorColumn->setColumnName($discriminatorColumnAnnot->name);

                    if (! empty($discriminatorColumnAnnot->columnDefinition)) {
                        $discriminatorColumn->setColumnDefinition($discriminatorColumnAnnot->columnDefinition);
                    }

                    if (! empty($discriminatorColumnAnnot->type)) {
                        $discriminatorColumn->setType(Type::getType($discriminatorColumnAnnot->type));
                    }

                    if (! empty($discriminatorColumnAnnot->length)) {
                        $discriminatorColumn->setLength($discriminatorColumnAnnot->length);
                    }
                }

                if (empty($discriminatorColumn->getColumnName())) {
                    throw Mapping\MappingException::nameIsMandatoryForDiscriminatorColumns($reflectionClass->getName());
                }

                $classMetadata->setDiscriminatorColumn($discriminatorColumn);

                // Evaluate @DiscriminatorMap annotation
                if (isset($classAnnotations[Annotation\DiscriminatorMap::class])) {
                    /** @var Annotation\DiscriminatorMap $discriminatorMapAnnotation */
                    $discriminatorMapAnnotation = $classAnnotations[Annotation\DiscriminatorMap::class];
                    $discriminatorMap           = $discriminatorMapAnnotation->value;

                    $classMetadata->setDiscriminatorMap($discriminatorMap);
                }
            }
        }

        return $classMetadata;
    }
621778
public function parse($annotation, \ReflectionClass $refClass, Endpoint $endpoint)
    {
        $field = new FieldDefinition();

        if ($annotation->name) {
            $field->setName($annotation->name);
        } else {
            $field->setName(lcfirst(ClassUtils::getDefaultName($refClass->getName())));
        }

        $objectType = null;
        preg_match('/(\w+)\\\\Field\\\\(\w+)$/', $refClass->getName(), $matches);
        if (!isset($matches[1]) || !$endpoint->hasType($matches[1])) {
            $error = sprintf('Can`t resolve a valid object type for field "%s"', $refClass->getName());
            throw new \RuntimeException($error);
        }
        /** @var ObjectDefinitionInterface $objectDefinition */
        $objectDefinition = $endpoint->getType($matches[1]);
        $objectDefinition->addField($field);

        $argAnnotations = $this->reader->getClassAnnotations($refClass);
        foreach ($argAnnotations as $argAnnotation) {
            if ($argAnnotation instanceof Annotation\Argument) {
                $this->resolveArgument($field, $argAnnotation);
            }
        }

        $field->setType(TypeUtil::normalize($annotation->type));
        $field->setList(TypeUtil::isTypeList($annotation->type));
        $field->setResolver($annotation->resolver ?? $refClass->getName());
        $field->setDeprecationReason($annotation->deprecationReason);
        $field->setDescription($annotation->description);
        $field->setComplexity($annotation->complexity);
        $field->setMaxConcurrentUsage($annotation->maxConcurrentUsage);

        foreach ($annotation->options as $option => $value) {
            $field->setMeta($option, $value);
        }

        if ($objectDefinition instanceof InterfaceDefinition) {
            $implementors = $objectDefinition->getImplementors();
            foreach ($implementors as $implementor) {
                $childType = $endpoint->getType($implementor);
                if ($childType instanceof FieldsAwareDefinitionInterface) {
                    $childType->addField($field);
                }
            }
        }
    }
422129
final protected function nonNullIfHasDefault(AbstractAnnotation $annotation): void
    {
        $type = $annotation->getTypeInstance();
        if ($type instanceof NonNull && $annotation->hasDefaultValue()) {
            $annotation->setTypeInstance($type->getWrappedType());
        }
    }
368088
private function convertClassAnnotationsToClassMetadata(
        array $classAnnotations,
        ReflectionClass $reflectionClass,
        Mapping\ClassMetadata $parent
    ) {
        switch (true) {
            case isset($classAnnotations[Annotation\Entity::class]):
                return $this->convertClassAnnotationsToEntityClassMetadata(
                    $classAnnotations,
                    $reflectionClass,
                    $parent
                );

                break;

            case isset($classAnnotations[Annotation\MappedSuperclass::class]):
                return $this->convertClassAnnotationsToMappedSuperClassMetadata(
                    $classAnnotations,
                    $reflectionClass,
                    $parent
                );
            case isset($classAnnotations[Annotation\Embeddable::class]):
                return $this->convertClassAnnotationsToEntityClassMetadata(
                    $classAnnotations,
                    $reflectionClass,
                    $parent
                );
            default:
                throw Mapping\MappingException::classIsNotAValidEntityOrMappedSuperClass($reflectionClass->getName());
        }
    }
264425
public function getAnnotation($annotation, $content = null, $options = array())
    {
        return new Annotation($this->addPrefix($annotation), $content, $options);
    }
288230
protected function addPackage(ComposerPackage $package)
    {
        $plugin = $this->rep->find($package->getName());

        // create new plugin if not exists
        if (!$plugin) {
            $plugin = new Plugin();
            $plugin->setName($package->getName());
        }

        list($vendor, $package) = explode('/', $plugin->getName());

        try {
            $data = $this->client->getPlugin($vendor, $package);
            $plugin->setTitle($data['title'])->setDescription($data['description']);
            if ($data['logo']) {
                $this->downloader->entity($data['logo'], $plugin, true);
            }
        } catch (\Exception $e) {
            // is not a critical error
        }

        $this->em->persist($plugin);
        $this->em->flush();
    }
391894
public static function add_annotation(annotation $annotation) {
        global $DB;

        $annotation->id = null;
        return $DB->insert_record('assignfeedback_editpdf_annot', $annotation);
    }