Backend\Core\Engine\AjaxAction::execute PHP Method

execute() public method

Execute the action We will build the classname, require the class and call the execute method.
public execute ( ) : Response
return Symfony\Component\HttpFoundation\Response
    public function execute()
    {
        $this->loadConfig();
        // build action-class-name
        $actionClass = 'Backend\\Modules\\' . $this->getModule() . '\\Ajax\\' . $this->getAction();
        if ($this->getModule() == 'Core') {
            $actionClass = 'Backend\\Core\\Ajax\\' . $this->getAction();
        }
        if (!class_exists($actionClass)) {
            throw new Exception('The class ' . $actionClass . ' could not be found.');
        }
        // create action-object
        $object = new $actionClass($this->getKernel(), $this->getAction(), $this->getModule());
        $object->setAction($this->getAction(), $this->getModule());
        $object->execute();
        return $object->getContent();
    }

Usage Example

Beispiel #1
0
 /**
  * @return Response
  */
 public function display()
 {
     return $this->ajaxAction->execute();
 }