Exemplo n.º 1
0
 public function build(\ReflectionClass $reflClass, $annot)
 {
     $definitionHolder = parent::build($reflClass, $annot);
     $definition = $definitionHolder['definition'];
     $id = $annot->value ?: $annot->name;
     if (empty($id)) {
         $serviceIdGenerator = new ServiceIdGenerator();
         $id = $serviceIdGenerator->generate($reflClass);
     }
     $definition->addTag('loso.controller');
     return array('id' => $id, 'definition' => $definition);
 }
Exemplo n.º 2
0
 public function build(\ReflectionClass $reflClass, $annot)
 {
     $definitionHolder = parent::build($reflClass, $annot);
     $definition = $definitionHolder['definition'];
     $id = $annot->name;
     if (empty($id)) {
         $serviceIdGenerator = new ServiceIdGenerator();
         $id = $serviceIdGenerator->generate($reflClass);
     }
     $entity = $annot->value ?: $annot->entity;
     $entityManager = !empty($annot->entityManager) ? $annot->entityManager : 'default';
     if (null === $entity) {
         throw new \InvalidArgumentException(sprintf('Entity name must be setted in @Repository for class "%s".', $reflClass->getName()));
     }
     $definition->addTag('loso.doctrine.repository', array('entity' => $entity, 'entityManager' => $entityManager));
     return array('id' => $id, 'definition' => $definition);
 }
Exemplo n.º 3
0
 public function build(\ReflectionClass $reflClass, $annot)
 {
     $definitionHolder = parent::build($reflClass, $annot);
     $definition = $definitionHolder['definition'];
     $id = $annot->value ?: $annot->name;
     if (empty($id)) {
         $serviceIdGenerator = new ServiceIdGenerator();
         $id = $serviceIdGenerator->generate($reflClass);
     }
     if (isset($annot->scope)) {
         $definition->setScope($annot->scope);
     }
     if (isset($annot->public)) {
         $definition->setPublic($annot->public);
     }
     if (isset($annot->factoryMethod)) {
         $definition->setFactoryMethod($annot->factoryMethod);
     }
     if (isset($annot->factoryService)) {
         $definition->setFactoryService($annot->factoryService);
     }
     if (isset($annot->configurator)) {
         if (is_string($annot->configurator)) {
             $definition->setConfigurator($annot->configurator);
         } else {
             $definition->setConfigurator(array($this->resolveServices($annot->configurator[0]), $annot->configurator[1]));
         }
     }
     if (isset($annot->tags)) {
         if (!is_array($annot->tags)) {
             throw new \InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in %s.', $id, $reflClass->getName()));
         }
         foreach ($annot->tags as $tag) {
             if (!isset($tag['name'])) {
                 throw new \InvalidArgumentException(sprintf('A "tags" entry is missing a "name" key must be an array for service "%s" in %s.', $id, $reflClass->getName()));
             }
             $name = $tag['name'];
             unset($tag['name']);
             $definition->addTag($name, $tag);
         }
     }
     return array('id' => $id, 'definition' => $definition);
 }