Esempio n. 1
0
 /**
  * @param ParsedReflectionClass|ParsedReflectionMethod|ParsedReflectionProperty $point
  * {@inheritdoc}
  */
 public function matches($point)
 {
     $expectedClass = $this->expectedClass;
     if (!$point instanceof $expectedClass) {
         return false;
     }
     $aliases = $point->getNamespaceAliases();
     $this->annotationReader->setImports($aliases);
     $annotation = $this->annotationReader->{$this->annotationMethod}($point, $this->annotationName);
     return (bool) $annotation;
 }
Esempio n. 2
0
 /**
  * Checks the class for possible component and register it in the container if needed
  *
  * @param ReflectionClass $class Instance of class reflection
  * @param ContainerBuilder $container
  *
  * @return bool True if component is registered
  */
 protected function checkAndRegisterComponent(ReflectionClass $class, ContainerBuilder $container)
 {
     $this->reader->setImports($class->getNamespaceAliases());
     $serviceName = str_replace('\\', '.', $class->getName());
     $annotation = $this->reader->getClassAnnotation($class, self::ANNOTATION_CLASS);
     if (!$annotation) {
         return false;
     }
     $definition = $container->register($serviceName, $class->getName());
     $constructor = $class->getConstructor();
     if ($constructor) {
         $this->bindConstructorArgs($constructor, $definition, $container);
     }
     if ((string) $annotation) {
         // Make an alias for annotation
         $container->setAlias($annotation, $serviceName);
     }
     return true;
 }