예제 #1
0
 /**
  * Listener method for the Enlight_Controller_Front_DispatchLoopStartup event.
  *
  * @param \Enlight_Controller_EventArgs $args
  */
 public function onDispatchLoopStartup(Enlight_Controller_EventArgs $args)
 {
     $this->request = $args->getSubject()->Request();
     $this->response = $args->getSubject()->Response();
     if ($this->request->getModuleName() != 'api') {
         return;
     }
     $this->isApiCall = true;
     $router = new \ShopwarePlugins\RestApi\Components\Router();
     $router->assembleRoute($this->request, $this->response);
 }
예제 #2
0
 /**
  * This pre-dispatch event-hook checks backend permissions
  *
  * @param \Enlight_Event_EventArgs $args
  * @throws Enlight_Controller_Exception
  * @return void
  */
 public function onPreDispatchBackend(Enlight_Event_EventArgs $args)
 {
     $this->action = $args->getSubject();
     $this->request = $this->action->Request();
     $this->aclResource = strtolower($this->request->getControllerName());
     if ($this->request->getModuleName() != 'backend' || in_array($this->aclResource, array('error'))) {
         return;
     }
     if ($this->shouldAuth()) {
         if ($this->checkAuth() === null) {
             if ($this->request->isXmlHttpRequest()) {
                 throw new Enlight_Controller_Exception('Unauthorized', 401);
             } else {
                 $this->action->redirect('backend/');
             }
         }
     } else {
         $this->initLocale();
     }
 }
예제 #3
0
 /**
  * Returns the full path of the action name.
  * To generate the full action path the module, controller and action name must be set in the given request object.
  * The module, controller and action path is imploded by '_'.
  *
  * @param Enlight_Controller_Request_Request $request
  * @return string
  */
 public function getFullActionName(Enlight_Controller_Request_Request $request)
 {
     $parts = array($this->formatModuleName($request->getModuleName()), $this->formatControllerName($request->getControllerName()), $this->formatActionName($request->getActionName()));
     return implode('_', $parts);
 }
예제 #4
0
 /**
  * @param Request $request
  * @return string
  */
 private function buildControllerName(Request $request)
 {
     $controllerName = strtolower($request->getModuleName() . '/' . $request->getControllerName());
     return $controllerName;
 }