コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function postFilter($url, Context $context)
 {
     if (!preg_match('|^[a-z]+://|', $url) && $url[0] !== '/') {
         $url = rtrim($context->getBaseUrl(), '/') . '/' . $url;
     }
     return $url;
 }
コード例 #2
0
 private function isSecure(Context $context, $params)
 {
     if ($context->isAlwaysSecure()) {
         $secure = true;
     } elseif (!$context->isSecure()) {
         $secure = false;
     } elseif (!empty($params['sUseSSL']) || !empty($params['forceSecure'])) {
         $secure = true;
     } elseif (!empty($params['controller']) && in_array($params['controller'], $this->secureControllers)) {
         $secure = true;
     } else {
         $secure = false;
     }
     return $secure;
 }
コード例 #3
0
ファイル: EventMatcher.php プロジェクト: GerDner/luck-docker
 /**
  * {@inheritdoc}
  */
 public function match($pathInfo, Context $context)
 {
     if (strpos($pathInfo, '/backend/') === 0 || strpos($pathInfo, '/api/') === 0) {
         return $pathInfo;
     }
     if ($context->getShopId() === null) {
         //only frontend
         return $pathInfo;
     }
     $request = new EnlightRequest();
     $request->setBaseUrl($context->getBaseUrl());
     $request->setPathInfo($pathInfo);
     $event = $this->eventManager->notifyUntil('Enlight_Controller_Router_Route', ['request' => $request, 'context' => $context]);
     return $event !== null ? $event->getReturn() : false;
 }
コード例 #4
0
ファイル: Router.php プロジェクト: GerDner/luck-docker
 /**
  * @param \Enlight_Event_EventArgs $args
  */
 public function onAfterRegisterShop(\Enlight_Event_EventArgs $args)
 {
     /** @var $container Container */
     $container = $args->getSubject();
     /** @var $router \Shopware\Components\Routing\RouterInterface  */
     $router = $container->get('router');
     /** @var $shop \Shopware\Models\Shop\Shop */
     $shop = $container->get('shop');
     /** @var $config \Shopware_Components_Config */
     $config = $container->get('config');
     // Register the shop (we're to soon)
     $config->setShop($shop);
     $context = $router->getContext();
     $newContext = Context::createFromShop($shop, $config);
     // Reuse the host
     if ($newContext->getHost() === null) {
         $newContext->setHost($context->getHost());
         $newContext->setBaseUrl($context->getBaseUrl());
         // Reuse https
         if (!$newContext->isSecure()) {
             $newContext->setSecure($context->isSecure());
             $newContext->setSecureBaseUrl($context->getSecureBaseUrl());
         }
     }
     // Reuse the global params like controller and action
     $globalParams = $context->getGlobalParams();
     $newContext->setGlobalParams($globalParams);
     $router->setContext($newContext);
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function preFilter($params, Context $context)
 {
     if (isset($params['sDetails']) && isset($params['action']) && $params['action'] == 'detail') {
         $params['sArticle'] = $params['sDetails'];
         unset($params['sDetails']);
     }
     if (isset($params['action'])) {
         $params = array_merge(['action' => null], $params);
     }
     if (isset($params['controller'])) {
         $params = array_merge(['controller' => null], $params);
     }
     unset($params['sUseSSL'], $params['fullPath'], $params['appendSession'], $params['forceSecure'], $params['sCoreId']);
     unset($params['rewriteOld'], $params['rewriteAlias'], $params['rewriteUrl']);
     if (isset($params['controller']) && $params['controller'] == 'detail' && $context->isRemoveCategory()) {
         unset($params['sCategory']);
     }
     return $params;
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function match($pathInfo, Context $context)
 {
     if (strpos($pathInfo, '/backend/') === 0 || strpos($pathInfo, '/api/') === 0) {
         return $pathInfo;
     }
     if ($context->getShopId() === null) {
         // only frontend
         return $pathInfo;
     }
     // Rewrites queries
     $params = $context->getParams();
     $params = $this->queryAliasMapper->replaceShortParams($params);
     /* templates/_emotion/frontend/_resources/javascript/jquery.shopware.js */
     if (isset($params['sAction'])) {
         $params['action'] = $params['sAction'];
     }
     if (isset($params['sViewport'])) {
         $params['controller'] = $params['sViewport'];
     }
     $context->setParams($params);
     // /widgets and /index supports short request queries
     if ($pathInfo === '/' || strpos($pathInfo, '/widgets/') === 0) {
         return $pathInfo;
     }
     $pathInfo = ltrim($pathInfo, '/');
     $statement = $this->getRouteStatement();
     $statement->bindValue(':shopId', $context->getShopId(), \PDO::PARAM_INT);
     $statement->bindValue(':pathInfo', $pathInfo, \PDO::PARAM_STR);
     if ($statement->execute() && $statement->rowCount() > 0) {
         $route = $statement->fetch(\PDO::FETCH_ASSOC);
         $query = $this->getQueryFormOrgPath($route['orgPath']);
         if (empty($route['main']) || $route['shopId'] != $context->getShopId()) {
             $query['rewriteAlias'] = true;
         } else {
             $query['rewriteUrl'] = true;
         }
         return $query;
     }
     return $pathInfo;
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function preFilter($params, Context $context = null)
 {
     // add support for "shopware.php?sViewport,cat&sCategory=3"
     if (is_string($params)) {
         $params = parse_url($params, PHP_URL_QUERY);
         $params = str_replace(',', '=', $params);
         parse_str($params, $params);
     }
     $globalParams = $context->getGlobalParams();
     if (isset($params['sViewport'])) {
         $params['controller'] = $params['sViewport'];
     }
     if (isset($params['sAction'])) {
         $params['action'] = $params['sAction'];
     }
     unset($params['title'], $params['sViewport'], $params['sAction']);
     if (isset($params['controller']) || isset($params['module'])) {
         if (isset($params['module'])) {
             unset($globalParams['controller']);
         }
         unset($globalParams['controller'], $globalParams['action']);
     }
     /** @see \sArticles::buildNavigation */
     if (isset($params['sDetails'])) {
         $params['sArticle'] = $params['sDetails'];
         unset($params['sDetails']);
     }
     /** @see \Shopware_Controllers_Backend_Customer::performOrderAction */
     if (!isset($params['controller']) && isset($params['action']) && $params['action'] == 'performOrderRedirect') {
         $params['module'] = 'backend';
         $params['controller'] = 'customer';
     }
     /** @see \Shopware_Controllers_Widgets_Emotion */
     if (!isset($params['module']) && isset($globalParams['module']) && $globalParams['module'] == 'widgets') {
         $params['module'] = 'frontend';
     }
     $params = array_merge($globalParams, $params);
     $context->setParams($params);
     return $params;
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 public function generate(array $params, Context $context)
 {
     $route = [];
     $module = isset($params[$context->getModuleKey()]) ? $params[$context->getModuleKey()] : $this->dispatcher->getDefaultModule();
     $controller = isset($params[$context->getControllerKey()]) ? $params[$context->getControllerKey()] : $this->dispatcher->getDefaultControllerName();
     $action = isset($params[$context->getActionKey()]) ? $params[$context->getActionKey()] : $this->dispatcher->getDefaultAction();
     unset($params[$context->getModuleKey()], $params[$context->getControllerKey()], $params[$context->getActionKey()]);
     if ($module != $this->dispatcher->getDefaultModule()) {
         $route[] = $module;
     }
     if (count($params) > 0 || $controller != $this->dispatcher->getDefaultControllerName() || $action != $this->dispatcher->getDefaultAction()) {
         $route[] = $controller;
     }
     if (count($params) > 0 || $action != $this->dispatcher->getDefaultAction()) {
         $route[] = $action;
     }
     foreach ($params as $key => $value) {
         $route[] = $key;
         $route[] = $value;
     }
     $route = array_map('urlencode', $route);
     return implode($this->separator, $route);
 }
コード例 #9
0
ファイル: Router.php プロジェクト: GerDner/luck-docker
 /**
  * Sets a global parameter.
  *
  * @see \Shopware_Controllers_Backend_Newsletter::initMailing
  * @see \Enlight_Controller_Router::setGlobalParam
  * @deprecated Use the context
  * @param string $name
  * @param string $value
  * @return self
  */
 public function setGlobalParam($name, $value)
 {
     $this->context->setGlobalParam($name, $value);
     return $this;
 }
コード例 #10
0
 /**
  * Fills up default values for module, controller and action
  *
  * @param Context $context
  * @param array $query
  * @return array
  */
 private function fillDefaults(Context $context, $query)
 {
     $defaults = [$context->getModuleKey() => $this->dispatcher->getDefaultModule(), $context->getControllerKey() => $this->dispatcher->getDefaultControllerName(), $context->getActionKey() => $this->dispatcher->getDefaultAction()];
     $query = array_merge($defaults, $query);
     return $query;
 }
コード例 #11
0
 /**
  * @param array $list
  * @param Context $context
  * @return array
  * @throws \Doctrine\DBAL\DBALException
  */
 private function rewriteList(array $list, Context $context)
 {
     $query = $this->getAssembleQuery();
     $statement = $this->connection->executeQuery($query, [':shopId' => $context->getShopId(), ':orgPath' => $list], [':shopId' => \PDO::PARAM_INT, ':orgPath' => Connection::PARAM_STR_ARRAY]);
     $rows = $statement->fetchAll(\PDO::FETCH_KEY_PAIR);
     foreach ($list as $key => $orgPath) {
         if (isset($rows[$orgPath])) {
             $list[$key] = $rows[$orgPath];
         } else {
             $list[$key] = false;
         }
     }
     return $list;
 }