/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
lib/internal/Magento/Framework/Module/Dir/ReverseResolver.php
54 строки
1 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 17:47
22 окт 2025, 17:47
1b769b7
Код
Авторство
О чём код?
<?php /** * Copyright 2014 Adobe * All Rights Reserved. */ namespace Magento\Framework\Module\Dir; use Magento\Framework\Module\Dir; use Magento\Framework\Module\ModuleListInterface; /** * Resolves file/directory paths to modules they belong to */ class ReverseResolver { /** * @var ModuleListInterface */ protected $_moduleList; /** * @var Dir */ protected $_moduleDirs; /** * @param ModuleListInterface $moduleList * @param Dir $moduleDirs */ public function __construct(ModuleListInterface $moduleList, Dir $moduleDirs) { $this->_moduleList = $moduleList; $this->_moduleDirs = $moduleDirs; } /** * Retrieve fully-qualified module name, path belongs to * * @param string $path Full path to file or directory * @return string|null */ public function getModuleName($path) { $path = $path !== null ? str_replace('\\', '/', $path) : ''; foreach ($this->_moduleList->getNames() as $moduleName) { $moduleDir = $this->_moduleDirs->getDir($moduleName); $moduleDir = str_replace('\\', '/', $moduleDir); if ($path == $moduleDir || strpos($path, $moduleDir . '/') === 0) { return $moduleName; } } return null; } }