/** * Call this one *from* your aspect, in order to proceed with the * execution. If you pass any arguments to this method, they will override * the original arguments when proceeding to the call. * * @return void */ public function proceed() { $target = $this->_reflectionFactory->getMethod($this->_class, $this->_method); if (!$target->isPublic()) { $target->setAccessible(true); } $arguments = func_get_args(); if (empty($arguments)) { $arguments = $this->_args; } $this->_result = $target->invokeArgs($this->_object, $arguments); return $this->_result; }
private function _injectConstructorArguments(BeanDefinition $bean) { if ($bean->isCreatedWithFactoryBean()) { $factoryMethod = $bean->getFactoryMethod(); $factoryBean = $bean->getFactoryBean(); $def = $this->_container->getBeanDefinition($factoryBean); $class = $def->getClass(); $rMethod = $this->_reflectionFactory->getMethod($class, $factoryMethod); $annotations = $this->_reflectionFactory->getMethodAnnotations($class, $factoryMethod); $this->_applyToConstructor($rMethod, $annotations, $bean); } else { if ($bean->isCreatedByConstructor()) { $class = $bean->getClass(); $rClass = $this->_reflectionFactory->getClass($class); $rMethod = $rClass->getConstructor(); if ($rMethod) { $annotations = $this->_reflectionFactory->getMethodAnnotations($class, $rMethod->getName()); $this->_applyToConstructor($rMethod, $annotations, $bean); } } } }
/** * Calls the specified method from the specifed object using the specified * arguments map. * * @param object $object * @param string $method Method name * @param array $arguments Map of arguments, where key is argument name, * and value is argument value. * * @return mxied */ private function invokeAction($object, $method, array $arguments) { $methodInfo = $this->reflectionFactory->getMethod(get_class($object), $method); $parameters = $methodInfo->getParameters(); $values = array(); $total = count($parameters); for ($i = 0; $i < $total; $i++) { $parameter = array_shift($parameters); $name = $parameter->getName(); if (isset($arguments[$name])) { $values[] = $arguments[$name]; } else { if ($parameter->isOptional()) { $values[] = $parameter->getDefaultValue(); } else { $ctl = get_class($object); throw new MvcException("Missing required argument: {$name} for action {$ctl}:{$method}"); } } } return $methodInfo->invokeArgs($object, $values); }