Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ReverseResolver.php
Go to the documentation of this file.
1 <?php
9 
12 
14 {
18  protected $_moduleList;
19 
23  protected $_moduleDirs;
24 
29  public function __construct(ModuleListInterface $moduleList, Dir $moduleDirs)
30  {
31  $this->_moduleList = $moduleList;
32  $this->_moduleDirs = $moduleDirs;
33  }
34 
41  public function getModuleName($path)
42  {
43  $path = str_replace('\\', '/', $path);
44  foreach ($this->_moduleList->getNames() as $moduleName) {
45  $moduleDir = $this->_moduleDirs->getDir($moduleName);
46  $moduleDir = str_replace('\\', '/', $moduleDir);
47  if ($path == $moduleDir || strpos($path, $moduleDir . '/') === 0) {
48  return $moduleName;
49  }
50  }
51  return null;
52  }
53 }
__construct(ModuleListInterface $moduleList, Dir $moduleDirs)