componentRegistrar = $componentRegistrar; $this->_string = $string; } /** * @param string $fileId * @return string * @throws \Magento\Framework\Exception\LocalizedException */ public function getFixture($fileId) { list($moduleName, $filePath) = \Magento\Framework\View\Asset\Repository::extractModule( $this->normalizePath($fileId) ); return $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName) . '/' . $filePath; } /** * Remove excessive "." and ".." parts from a path * * For example foo/bar/../file.ext -> foo/file.ext * * @param string $path * @return string */ public static function normalizePath($path) { $parts = explode('/', $path); $result = []; foreach ($parts as $part) { if ('..' === $part) { if (!count($result) || ($result[count($result) - 1] == '..')) { $result[] = $part; } else { array_pop($result); } } elseif ('.' !== $part) { $result[] = $part; } } return implode('/', $result); } }