Пример #1
0
 /**
  * Executes the action corresponding to the current request
  * 
  * @param Framework\Request $request
  */
 public function execute(Request &$request, Response &$response)
 {
     $this->_request = $request;
     $this->_response = $response;
     if ($this->isInternal && $this->_request->getState() == \framework\core\Request::FIRST_REQUEST) {
         $this->_response->setStatus(\framework\core\Response::OUTSIDE_ACCESS_FORBIDDEN);
     } else {
         if ($this->_before($this->_request, $this->_response) !== false && call_user_func_array(array($this, 'processAction'), $this->_request->getParams()) !== false && $this->_after($this->_request, $this->_response) !== false) {
             if ($this->usesView) {
                 if ($this->usesLayout == false) {
                     $this->setLayout(false);
                 }
                 if ($this->_view === null) {
                     $this->setView($this->_request->getAction());
                 }
                 $this->_response->set($this->createView($this->_request->getModule(), $this->_view, $this->_vars));
             }
             $this->_response->setStatus(\framework\core\Response::SUCCESS);
         } else {
             $this->_response->setStatus(\framework\core\Response::ERROR);
         }
     }
     return $this->_response;
 }
Пример #2
0
 /**
  * Executes the action corresponding to the current request
  *
  * @param Framework\Request $request
  */
 public function execute(Request &$request, Response &$response)
 {
     $this->_request = $request;
     $this->_response = $response;
     if ($this->isInternal && $this->_request->getState() == \framework\core\Request::FIRST_REQUEST) {
         $this->_response->setStatus(\framework\core\Response::OUTSIDE_ACCESS_FORBIDDEN);
     } else {
         // check if the module's dependencies are not unsatisfied (they can be SCHRODINGER !)
         if ($this->getConfig()->get('modules.' . $request->getModule() . '.dependenciesSatisfied') !== \framework\libs\ConfigBuilder::DEPENDENCIES_UNSATISFIED) {
             //Preparation to "before" and "after" events lauching
             //$classPath = 'application\\modules\\' . $request->getModule() . '\\controllers\\' . $request->getAction();
             $beforeName = 'before' . ucfirst($request->getAction());
             $afterName = 'after' . ucfirst($request->getAction());
             //Launch Before event
             $this->raiseEvent($beforeName);
             if ($this->_before() !== false && call_user_func_array(array($this, 'processAction'), $this->_request->getParams()) !== false && $this->_after() !== false) {
                 //Lauch After event
                 $this->raiseEvent($afterName);
                 if ($this->usesView) {
                     if ($this->usesLayout == false) {
                         $this->setLayout(false);
                     }
                     if ($this->_view === null) {
                         $this->setView($this->_request->getAction());
                     }
                     $this->_response->set($this->createView($this->_request->getModule(), $this->_view, $this->_vars));
                 }
                 $this->_response->setStatus(\framework\core\Response::SUCCESS);
             } else {
                 $this->_response->setStatus(\framework\core\Response::ERROR);
             }
         } else {
             throw new \framework\core\ControllerDependencyException($request->getModule(), $this->getConfig('modules'));
         }
     }
     return $this->_response;
 }