/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
setup/src/Magento/Setup/Module/Dependency/Parser/Config/Xml.php
83 строки
2 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 11:23
22 окт 2025, 11:23
6c2f6e6
Код
Авторство
О чём код?
<?php /** * Copyright 2015 Adobe * All Rights Reserved. */ namespace Magento\Setup\Module\Dependency\Parser\Config; use Magento\Setup\Module\Dependency\ParserInterface; /** * Config xml parser */ class Xml implements ParserInterface { /** * Template method. Main algorithm * * {@inheritdoc} */ public function parse(array $options) { $this->checkOptions($options); $modules = []; foreach ($options['files_for_parse'] as $file) { $config = $this->getModuleConfig($file); $modules[] = $this->extractModuleName($config); } return $modules; } /** * Template method. Check passed options step * * @param array $options * @return void * @throws \InvalidArgumentException */ protected function checkOptions($options) { if (!isset( $options['files_for_parse'] ) || !is_array( $options['files_for_parse'] ) || !$options['files_for_parse'] ) { throw new \InvalidArgumentException('Parse error: Option "files_for_parse" is wrong.'); } } /** * Template method. Extract module step * * @param \SimpleXMLElement $config * @return string */ protected function extractModuleName($config) { return $this->prepareModuleName((string)$config->attributes()->name); } /** * Template method. Load module config step * * @param string $file * @return \SimpleXMLElement */ protected function getModuleConfig($file) { return \simplexml_load_file($file)->xpath('/config/module')[0]; } /** * Prepare module name * * @param string $name * @return string */ protected function prepareModuleName($name) { return str_replace('_', '\\', $name); } }