/** * @param IEventListener $service * @param Method $method */ public function __construct($service, Method $method) { $this->service = $service; $this->method = $method; $this->annotations = $method->getAnnotations(); }
/** * Creates method list * (may take a time..) * * @return array */ public function createMethodList() { /** @var $robotLoader RobotLoader */ $robotLoader = $this->context->getService('robotLoader'); foreach ($robotLoader->getIndexedClasses() as $class => $file) { if (Strings::match($file, "~\\Nette~")) { continue; } $creflection = new Nette\Reflection\ClassType($class); foreach ($creflection->getMethods() as $method) { $mreflection = new Method($class, $method->getName()); if ($mreflection->hasAnnotation('cron')) { $m = new stdClass(); $m->name = $mreflection->getName(); $m->class = $mreflection->getDeclaringClass()->getName(); $m->annotations = $mreflection->getAnnotations(); $this->methods[] = $m; } } } return $this->methods; }
/** * Create definition statement for method * @param ServiceDefinition $definition * @param \Nette\Reflection\Method $method */ protected function autowireParams(ServiceDefinition $definition, \Nette\Reflection\Method $method) { $parameters = $method->getParameters(); foreach ($parameters as $num => $param) { /** @var \Nette\Reflection\Parameter $param */ if ($targetClass = $param->getClass()) { if ($targetClass->getName() === 'Kdyby\\Doctrine\\EntityDao' && !isset($definition->factory->arguments[$num])) { $annotations = $method->getAnnotations(); $entity = $this->getEntityName($param, $annotations); if ($definition->factory === NULL) { $definition->setFactory($definition->class); } $definition->factory->arguments[$num] = new \Nette\DI\Statement('@doctrine.dao', array($entity)); } } } }