Example #1
0
 /**
  * (non-PHPdoc)
  * @see Ding\Bean\Lifecycle.IAfterDefinitionListener::afterDefinition()
  */
 public function afterDefinition(BeanDefinition $bean)
 {
     foreach ($bean->getMethodInjections() as $method) {
         $aspectBeanName = BeanDefinition::generateName('MethodInjectionAspect');
         $aspectBean = new BeanDefinition($aspectBeanName);
         $aspectBean->setClass('\\Ding\\Bean\\Factory\\Driver\\MethodInjectionAspect');
         $aspectBean->setProperties(array(new BeanPropertyDefinition('beanName', BeanPropertyDefinition::PROPERTY_SIMPLE, $method[1])));
         $this->_beans[$aspectBeanName] = $aspectBean;
         $aspectName = BeanDefinition::generateName('MethodInjectionAspect');
         $pointcutName = BeanDefinition::generateName('MethodInjectionPointcut');
         $pointcut = new PointcutDefinition($pointcutName, $method[0], 'invoke');
         $this->_aspectManager->setPointcut($pointcut);
         $aspect = new AspectDefinition($aspectName, array($pointcutName), AspectDefinition::ASPECT_METHOD, $aspectBeanName, '');
         $aspects = $bean->getAspects();
         $aspects[] = $aspect;
         $bean->setAspects($aspects);
     }
     return $bean;
 }