/** * {@inheritdoc} */ public function getDefinition($entryName) { $definition = new ObjectDefinition($entryName, $this->className); if ($this->lazy !== null) { $definition->setLazy($this->lazy); } if ($this->scope !== null) { $definition->setScope($this->scope); } if (!empty($this->constructor)) { $parameters = $this->fixParameters($definition, '__construct', $this->constructor); $constructorInjection = MethodInjection::constructor($parameters); $definition->setConstructorInjection($constructorInjection); } if (!empty($this->properties)) { foreach ($this->properties as $property => $value) { $definition->addPropertyInjection(new PropertyInjection($property, $value)); } } if (!empty($this->methods)) { foreach ($this->methods as $method => $calls) { foreach ($calls as $parameters) { $parameters = $this->fixParameters($definition, $method, $parameters); $methodInjection = new MethodInjection($method, $parameters); $definition->addMethodInjection($methodInjection); } } } return $definition; }
private function readInjectableAnnotation(ReflectionClass $class, ObjectDefinition $definition) { try { /** @var $annotation Injectable|null */ $annotation = $this->getAnnotationReader()->getClassAnnotation($class, 'DI\\Annotation\\Injectable'); } catch (UnexpectedValueException $e) { throw new DefinitionException(sprintf('Error while reading @Injectable on %s: %s', $class->getName(), $e->getMessage()), 0, $e); } if (!$annotation) { return; } if ($annotation->getScope()) { $definition->setScope($annotation->getScope()); } if ($annotation->isLazy() !== null) { $definition->setLazy($annotation->isLazy()); } }