addMethodInjection() public method

public addMethodInjection ( DI\Definition\ObjectDefinition\MethodInjection $methodInjection )
$methodInjection DI\Definition\ObjectDefinition\MethodInjection
Example #1
0
 /**
  * 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);
         }
     }
 }