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); } }
/** * Execute all cron jobs. * * @throws Exception In case something went wrong. */ public function run() { $scanner = new Customweb_Annotation_Scanner(); $annotations = $scanner->find('Customweb_Cron_Annotation_Cron', $this->packages); $approxFinalizeTime = 4; $maxExecutionTime = Customweb_Util_System::getMaxExecutionTime() - $approxFinalizeTime; $start = $this->getStartTime(); $endTime = $start + $maxExecutionTime; foreach ($annotations as $identifier => $annotation) { if ($endTime < time()) { break; } if ($annotation instanceof Customweb_Cron_Annotation_Cron) { $parts = explode('::', $identifier, 2); $className = $parts[0]; $methodName = $parts[1]; $this->invoke($className, $methodName, $annotation); } } }
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; }
/** * Search the given package list for controllers. The method returns a map * with the controller names as key and the class name as the value. * * @return array */ protected function getControllers() { if ($this->controllers === null) { $scanner = new Customweb_Annotation_Scanner(); $annotations = $scanner->find('Customweb_Mvc_Controller_Annotation_Controller', $this->getControllerPackages()); foreach ($annotations as $className => $annotation) { if ($annotation instanceof Customweb_Mvc_Controller_Annotation_Controller) { $controllerName = $annotation->getName(); if (empty($controllerName)) { throw new Exception(Customweb_Core_String::_("The class '@className' is annotated with Customweb_Mvc_Controller_Annotation_Controller. However it does not provide a controller name.")->format(array('@className' => $className))); } $this->controllers[strtolower($controllerName)] = $className; } } } return $this->controllers; }
/** * Returns a list of payment methods found in the packages. * * @return Customweb_Payment_Annotation_Method[] */ protected final function getAnnotationMap() { if ($this->methodAnnotations === null) { $this->methodAnnotations = array(); $scanner = new Customweb_Annotation_Scanner(); $packages = $this->getMethodPackages(); if (!is_array($packages)) { $packages = array($packages); } $annotations = $scanner->find('Customweb_Payment_Annotation_Method', $packages); foreach ($annotations as $className => $annotation) { if ($annotation instanceof Customweb_Payment_Annotation_Method) { $this->methodAnnotations[$className] = $annotation; } } } return $this->methodAnnotations; }