protected final function scan() { $scanner = new Customweb_Annotation_Scanner(); $annotations = $scanner->find('Customweb_DependencyInjection_Bean_Provider_Annotation_Bean', $this->packages); foreach ($annotations as $className => $annotationInstance) { if (empty($annotationInstance->beanId)) { $annotationInstance->beanId = $className; } $this->beans[] = Customweb_DependencyInjection_Bean_Provider_Annotation_Util::createBeanInstance($annotationInstance->beanId, $className); } }
protected function invoke($className, $methodName, Customweb_Cron_Annotation_Cron $annotation) { $reflector = new ReflectionClass($className); $method = $reflector->getMethod($methodName); $object = null; if (!$method->isStatic()) { $bean = Customweb_DependencyInjection_Bean_Provider_Annotation_Util::createBeanInstance($className, $className); $object = $bean->getInstance($this->getContainer()); } $args = $this->resolveInvocationArguements($method); $method->invoke($object, $args); }
public function getForms() { if ($this->forms === null) { $this->forms = array(); $scanner = new Customweb_Annotation_Scanner(); $formAnnotations = $scanner->find('Customweb_Payment_BackendOperation_Form_Annotation_BackendForm', $this->getFormPackages()); foreach ($formAnnotations as $className => $annotation) { $bean = Customweb_DependencyInjection_Bean_Provider_Annotation_Util::createBeanInstance($className, $className); $form = $bean->getInstance($this->getContainer()); if (!$annotation instanceof Customweb_Payment_BackendOperation_Form_Annotation_BackendForm) { throw new Customweb_Core_Exception_CastException('Customweb_Payment_BackendOperation_Form_Annotation_BackendForm'); } if (!$form instanceof Customweb_Payment_BackendOperation_IForm) { throw new Customweb_Core_Exception_CastException('Customweb_Payment_BackendOperation_IForm'); } $key = self::findNextBiggerKey($this->forms, $annotation->getSortOrder()); $this->forms[$key] = $form; } ksort($this->forms); } return $this->forms; }
protected function instantiateController($className) { $key = strtolower($className); if (!isset($this->controllerInstances[$key])) { $container = new Customweb_DependencyInjection_Container_Extendable($this->getContainer()); $bean = Customweb_DependencyInjection_Bean_Provider_Annotation_Util::createBeanInstance($className, $className); $container->addBean(new Customweb_DependencyInjection_Bean_Object($this->getAdapter())); $container->addBean(new Customweb_DependencyInjection_Bean_Object($this)); $this->controllerInstances[$key] = $bean->getInstance($container); } return $this->controllerInstances[$key]; }
/** * This method returns the payment method wrapper object. * * @param Customweb_Payment_Authorization_IPaymentMethod $method * @return object */ public function getPaymentMethod(Customweb_Payment_Authorization_IPaymentMethod $method, $authorizationMethodName) { $keys = $this->getKeys($method, $authorizationMethodName); $className = $this->resolveClassName($this->getClassMap(), $keys); if ($className === false) { throw new Customweb_Payment_Authorization_Method_PaymentMethodResolutionException($method->getPaymentMethodName(), $authorizationMethodName); } $instanceKey = implode('_', $keys); if (!isset($this->paymentMethodInstances[$instanceKey][$className])) { // We inject the given class as regular bean, but we do not store it back into the container. However, // we have to inject any required dependency. $bean = Customweb_DependencyInjection_Bean_Provider_Annotation_Util::createBeanInstance($className, $className); $container = new Customweb_DependencyInjection_Container_Extendable($this->getContainer()); $container->addBean(new Customweb_DependencyInjection_Bean_Object($method)); if (!isset($this->paymentMethodInstances[$instanceKey])) { $this->paymentMethodInstances[$instanceKey] = array(); } $this->paymentMethodInstances[$instanceKey][$className] = $bean->getInstance($container); } return $this->paymentMethodInstances[$instanceKey][$className]; }