Ejemplo n.º 1
0
 /**
  * Will look for "aware" kind of interfaces and inject whatever necessary.
  *
  * @param BeanDefinition $def The Bean Definition
  * @param object $bean The bean
  *
  * @return void
  */
 public function fillAware(BeanDefinition $def, $bean)
 {
     $class = get_class($bean);
     $rClass = $this->_reflectionFactory->getClass($class);
     if ($rClass->implementsInterface('Ding\\Reflection\\IReflectionFactoryAware')) {
         $bean->setReflectionFactory($this->_reflectionFactory);
     }
     if ($rClass->implementsInterface('Ding\\Bean\\IBeanNameAware')) {
         $bean->setBeanName($def->getName());
     }
     if ($rClass->implementsInterface('Ding\\Logger\\ILoggerAware')) {
         $bean->setLogger(\Logger::getLogger($class));
     }
     if ($rClass->implementsInterface('Ding\\Container\\IContainerAware')) {
         $bean->setContainer($this);
     }
     if ($rClass->implementsInterface('Ding\\Resource\\IResourceLoaderAware')) {
         $bean->setResourceLoader($this);
     }
     if ($rClass->implementsInterface('Ding\\Aspect\\IAspectManagerAware')) {
         $bean->setAspectManager($this->_aspectManager);
     }
     if ($rClass->implementsInterface('Ding\\Bean\\IBeanDefinitionProvider')) {
         $this->registerBeanDefinitionProvider($bean);
     }
     if ($rClass->implementsInterface('Ding\\Bean\\Lifecycle\\IAfterConfigListener')) {
         $this->_lifecycleManager->addAfterConfigListener($bean);
     }
     if ($rClass->implementsInterface('Ding\\Bean\\Lifecycle\\IAfterDefinitionListener')) {
         $this->_lifecycleManager->addAfterDefinitionListener($bean);
     }
     if ($rClass->implementsInterface('Ding\\Bean\\Lifecycle\\IBeforeCreateListener')) {
         $this->_lifecycleManager->addBeforeCreateListener($bean);
     }
     if ($rClass->implementsInterface('Ding\\Bean\\Lifecycle\\IAfterCreateListener')) {
         $this->_lifecycleManager->addAfterCreateListener($bean);
     }
     if ($rClass->implementsInterface('Ding\\Bean\\Lifecycle\\IBeforeAssembleListener')) {
         $this->_lifecycleManager->addBeforeAssembleListener($bean);
     }
     if ($rClass->implementsInterface('Ding\\Bean\\Lifecycle\\IAfterAssembleListener')) {
         $this->_lifecycleManager->addAfterAssembleListener($bean);
     }
     if ($rClass->implementsInterface('Ding\\Aspect\\IAspectProvider')) {
         $this->_aspectManager->registerAspectProvider($bean);
     }
     if ($rClass->implementsInterface('Ding\\Aspect\\IPointcutProvider')) {
         $this->_aspectManager->registerPointcutProvider($bean);
     }
 }