public setConstructorInjection ( DI\Definition\ObjectDefinition\MethodInjection $constructorInjection ) | ||
$constructorInjection | DI\Definition\ObjectDefinition\MethodInjection |
/** * {@inheritdoc} */ public function getDefinition($name) { if (!class_exists($name) && !interface_exists($name)) { return null; } $definition = new ObjectDefinition($name); // Constructor $class = new \ReflectionClass($name); $constructor = $class->getConstructor(); if ($constructor && $constructor->isPublic()) { $definition->setConstructorInjection(MethodInjection::constructor($this->getParametersDefinition($constructor))); } return $definition; }
/** * Browse the object's methods looking for annotated methods. */ private function readMethods(ReflectionClass $class, ObjectDefinition $objectDefinition) { // This will look in all the methods, including those of the parent classes foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { if ($method->isStatic()) { continue; } $methodInjection = $this->getMethodInjection($method); if (!$methodInjection) { continue; } if ($method->isConstructor()) { $objectDefinition->setConstructorInjection($methodInjection); } else { $objectDefinition->addMethodInjection($methodInjection); } } }