Beispiel #1
0
 /**
  * Execute the action
  * We will build the classname, require the class and call the execute method.
  *
  * @return	void
  */
 public function execute()
 {
     // build action-class-name
     $actionClassName = 'Frontend' . SpoonFilter::toCamelCase($this->getModule() . '_' . $this->getAction());
     // require the config file, we know it is there because we validated it before (possible actions are defined by existance off the file).
     require_once FRONTEND_MODULES_PATH . '/' . $this->getModule() . '/actions/' . $this->getAction() . '.php';
     // validate if class exists (aka has correct name)
     if (!class_exists($actionClassName)) {
         throw new FrontendException('The actionfile is present, but the classname should be: ' . $actionClassName . '.');
     }
     // create action-object
     $this->object = new $actionClassName($this->getModule(), $this->getAction(), $this->getData());
     // validate if the execute-method is callable
     if (!is_callable(array($this->object, 'execute'))) {
         throw new FrontendException('The actionfile should contain a callable method "execute".');
     }
     // call the execute method of the real action (defined in the module)
     $this->object->execute();
     // set some properties
     $this->setOverwrite($this->object->getOverwrite());
     if ($this->object->getTemplatePath() !== null) {
         $this->setTemplatePath($this->object->getTemplatePath());
     }
 }