/** * (non-PHPdoc) * @see Ding\Bean\Lifecycle.IAfterDefinitionListener::afterDefinition() */ public function afterDefinition(BeanDefinition $bean) { $class = $bean->getClass(); $annotations = $this->reflectionFactory->getClassAnnotations($class); if ($annotations->contains('initmethod')) { $annotation = $annotations->getSingleAnnotation('initmethod'); if ($annotation->hasOption('method')) { $bean->setInitMethod($annotation->getOptionSingleValue('method')); } } if ($annotations->contains('destroymethod')) { $annotation = $annotations->getSingleAnnotation('destroymethod'); if ($annotation->hasOption('method')) { $bean->setDestroyMethod($annotation->getOptionSingleValue('method')); } } foreach ($this->reflectionFactory->getClass($class)->getMethods() as $method) { $methodName = $method->getName(); $annotations = $this->reflectionFactory->getMethodAnnotations($class, $methodName); if ($annotations->contains('postconstruct')) { $bean->setInitMethod($methodName); break; } if ($annotations->contains('predestroy')) { $bean->setDestroyMethod($methodName); break; } } return $bean; }