/** * Get an array of URNs * * @param OutputInterface $output * @return array */ private function getUrnDictionary(OutputInterface $output) { $files = $this->filesUtility->getXmlCatalogFiles('*.xml'); $files = array_merge($files, $this->filesUtility->getXmlCatalogFiles('*.xsd')); $urns = []; foreach ($files as $file) { $content = $this->rootDirRead->readFile($this->rootDirRead->getRelativePath($file[0])); $matches = []; preg_match_all('/schemaLocation="(urn\\:magento\\:[^"]*)"/i', $content, $matches); if (isset($matches[1])) { $urns = array_merge($urns, $matches[1]); } } $urns = array_unique($urns); $paths = []; foreach ($urns as $urn) { try { $paths[$urn] = $this->urnResolver->getRealPath($urn); } catch (\Exception $e) { // don't add unsupported element to array if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $output->writeln($e->getMessage()); } } } return $paths; }
public function testGetXmlCatalogFiles() { $actual = $this->model->getXmlCatalogFiles('*.xml'); $this->assertNotEmpty($actual); foreach ($actual as $file) { $this->assertStringEndsWith('.xml', $file[0]); } $actual = $this->model->getXmlCatalogFiles('*.xsd'); $this->assertNotEmpty($actual); foreach ($actual as $file) { $this->assertStringEndsWith('.xsd', $file[0]); } }