Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PathProcessor.php
Go to the documentation of this file.
1 <?php
2 
8 
10 
15 {
17  const ALL_STORE_CODE = 'all';
18 
22  private $storeManager;
23 
27  public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager)
28  {
29  $this->storeManager = $storeManager;
30  }
31 
38  private function stripPathBeforeStorecode($pathInfo)
39  {
40  $pathParts = explode('/', trim($pathInfo, '/'));
41  array_shift($pathParts);
42  $path = '/' . implode('/', $pathParts);
43  return explode('/', ltrim($path, '/'), 2);
44  }
45 
53  public function process($pathInfo)
54  {
55  $pathParts = $this->stripPathBeforeStorecode($pathInfo);
56  $storeCode = current($pathParts);
57  $stores = $this->storeManager->getStores(false, true);
58  if (isset($stores[$storeCode])) {
59  $this->storeManager->setCurrentStore($storeCode);
60  $path = '/' . (isset($pathParts[1]) ? $pathParts[1] : '');
61  } elseif ($storeCode === self::ALL_STORE_CODE) {
62  $this->storeManager->setCurrentStore(\Magento\Store\Model\Store::ADMIN_CODE);
63  $path = '/' . (isset($pathParts[1]) ? $pathParts[1] : '');
64  } else {
65  $path = '/' . implode('/', $pathParts);
66  }
67  return $path;
68  }
69 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$storeManager
$storeCode
Definition: indexer.php:15
__construct(\Magento\Store\Model\StoreManagerInterface $storeManager)