/** * @param ShopEntity $shop * @return Shop */ public static function createFromShopEntity(ShopEntity $shop) { $struct = new self(); $struct->setId($shop->getId()); $struct->setParentId($shop->getMain() ? $shop->getMain()->getId() : $shop->getId()); $struct->setIsDefault($shop->getDefault()); $struct->setName($shop->getName()); $struct->setHost($shop->getHost()); $struct->setPath($shop->getBasePath()); $struct->setUrl($shop->getBaseUrl()); $struct->setSecure($shop->getSecure()); $struct->setSecureHost($shop->getSecureHost()); $struct->setSecurePath($shop->getSecureBasePath()); if ($shop->getCategory()) { $struct->setCategory(Category::createFromCategoryEntity($shop->getCategory())); } if ($shop->getFallback()) { $struct->setFallbackId($shop->getFallback()->getId()); } return $struct; }
/** * @param string $path * @param Shop\Shop $shop * @param bool $isSecureRequest * @return string */ public function formatPathToUrl($path, Shop\Shop $shop, $isSecureRequest = false) { if ($isSecureRequest && $shop->getSecureBasePath()) { $targetPath = $shop->getSecureBasePath(); } else { $targetPath = $shop->getBasePath(); } return str_replace($this->rootDir, $targetPath, $path); }
/** * @param string $requestUri * @param Request $request * @param Shop $shop * @return string */ private function removeShopBaseUrl($requestUri, Request $request, Shop $shop) { $url = $shop->getBaseUrl(); $path = $shop->getBasePath(); if ($request->isSecure()) { $url = $shop->getSecureBaseUrl(); $path = $shop->getSecureBasePath(); } $requestUri = $this->removePartOfUrl($requestUri, $url); $requestUri = $this->removePartOfUrl($requestUri, $path); return $requestUri; }