/** * 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); }
/** * This methods sets the nocache-cookie if actions in the shop are triggerd */ public function setNoCacheCookie() { $controllerName = strtolower($this->request->getModuleName()) . '/' . strtolower($this->request->getControllerName()); if (isset($this->autoNoCacheControllers[$controllerName])) { $noCacheTag = $this->autoNoCacheControllers[$controllerName]; $this->setNoCacheTag($noCacheTag); } if (Shopware()->Shop()->get('defaultcustomergroup') != Shopware()->System()->sUSERGROUP) { $this->setNoCacheTag('price'); } if ($controllerName == 'frontend/checkout' || $controllerName == 'frontend/note') { if (empty(Shopware()->Session()->sBasketQuantity) && empty(Shopware()->Session()->sNotesQuantity)) { // remove checkout-cookie $this->setNoCacheTag('checkout', true); } } if ($controllerName == 'frontend/compare' && $this->request->getActionName() == 'delete_all') { // remove compare cookie $this->setNoCacheTag('compare', true); } if (!empty(Shopware()->Session()->sNotesQuantity)) { // set checkout-cookie $this->setNoCacheTag('checkout'); } if ($this->request->getModuleName() == 'frontend' && !empty(Shopware()->Session()->Admin)) { // set admin-cookie if admin session is present $this->setNoCacheTag('admin'); } if ($controllerName == 'frontend/account') { if (in_array($this->request->getActionName(), array('ajax_logout', 'logout'))) { $this->setNoCacheTag(''); } } }
/** * 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(); } }
/** * @see \Enlight_Controller_Router::setGlobalParam * @param EnlightRequest $request * @return array */ public static function getGlobalParamsFromRequest(EnlightRequest $request) { $globalParams = []; if ($request->getModuleName()) { $globalParams['module'] = $request->getModuleName(); if ($request->getControllerName() !== null) { $globalParams['controller'] = $request->getControllerName(); if ($request->getActionName() !== null) { $globalParams['action'] = $request->getActionName(); } } } return $globalParams; }
/** * {@inheritdoc} */ public function getModuleName() { if (parent::getModuleName() === null) { return null; } return strtolower(trim(parent::getModuleName())); }