/** * {@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; }
/** * {@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; }
/** * @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; }