当前位置: 首页>>代码示例>>PHP>>正文


PHP UrnResolver::getRealPath方法代码示例

本文整理汇总了PHP中Magento\Framework\Config\Dom\UrnResolver::getRealPath方法的典型用法代码示例。如果您正苦于以下问题:PHP UrnResolver::getRealPath方法的具体用法?PHP UrnResolver::getRealPath怎么用?PHP UrnResolver::getRealPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Config\Dom\UrnResolver的用法示例。


在下文中一共展示了UrnResolver::getRealPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetSchemaFile

 public function testGetSchemaFile()
 {
     $config = new \Magento\Framework\Config\Theme($this->urnResolverMock, null);
     $this->urnResolverMock->expects($this->exactly(2))->method('getRealPath')->with('urn:magento:framework:Config/etc/theme.xsd')->willReturn($this->urnResolver->getRealPath('urn:magento:framework:Config/etc/theme.xsd'));
     $this->assertEquals($this->urnResolver->getRealPath('urn:magento:framework:Config/etc/theme.xsd'), $config->getSchemaFile());
     $this->assertFileExists($config->getSchemaFile());
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:7,代码来源:ThemeTest.php

示例2: testReadWithInvalidXml

 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Invalid XML in file
  */
 public function testReadWithInvalidXml()
 {
     $this->_schemaLocatorMock->expects($this->any())->method('getPerFileSchema')->will($this->returnValue($this->urnResolver->getRealPath('urn:magento:framework:Config/Test/Unit/_files/reader/schema.xsd')));
     $this->_validationStateMock->expects($this->any())->method('isValidationRequired')->willReturn(true);
     $model = new Filesystem($this->_fileResolverMock, $this->_converterMock, $this->_schemaLocatorMock, $this->_validationStateMock, 'fileName', []);
     $this->_fileResolverMock->expects($this->once())->method('get')->will($this->returnValue([$this->_file]));
     $model->read('scope');
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:12,代码来源:FilesystemTest.php

示例3: testFileSchemaUsingInvalidXml

 public function testFileSchemaUsingInvalidXml()
 {
     if (!function_exists('libxml_set_external_entity_loader')) {
         $this->markTestSkipped('Skipped due to MAGETWO-45033');
     }
     $xmlFile = __DIR__ . '/_files/invalid_widget.xml';
     $schema = $this->urnResolver->getRealPath('urn:magento:module:Magento_Widget:etc/widget_file.xsd');
     $this->_validateFileExpectFailure($xmlFile, $schema);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:WidgetConfigTest.php

示例4: testFileSchemaUsingInvalidXml

 public function testFileSchemaUsingInvalidXml()
 {
     $xmlFile = __DIR__ . '/_files/invalid_fieldset.xml';
     $dom = new \DOMDocument();
     $dom->loadXML(file_get_contents($xmlFile));
     $schema = $this->urnResolver->getRealPath('urn:magento:framework:DataObject/etc/fieldset_file.xsd');
     $errors = \Magento\Framework\Config\Dom::validateDomDocument($dom, $schema);
     if (!$errors) {
         $this->fail('There is a problem with the schema.  A known bad XML file passed validation');
     }
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:11,代码来源:FieldsetConfigTest.php

示例5: testFileSchemaUsingInvalidXml

 public function testFileSchemaUsingInvalidXml()
 {
     if (!function_exists('libxml_set_external_entity_loader')) {
         $this->markTestSkipped('Skipped due to MAGETWO-45033');
     }
     $xmlFile = __DIR__ . '/_files/invalid_fieldset.xml';
     $dom = new \DOMDocument();
     $dom->loadXML(file_get_contents($xmlFile));
     $schema = $this->urnResolver->getRealPath('urn:magento:framework:DataObject/etc/fieldset_file.xsd');
     $errors = \Magento\Framework\Config\Dom::validateDomDocument($dom, $schema);
     if (!$errors) {
         $this->fail('There is a problem with the schema.  A known bad XML file passed validation');
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:FieldsetConfigTest.php

示例6: getUrnDictionary

 /**
  * 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;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:33,代码来源:XmlCatalogGenerateCommand.php

示例7: validateDomDocument

 /**
  * Validate dom document
  *
  * @param \DOMDocument $dom
  * @param string $schema Absolute schema file path or URN
  * @param string $errorFormat
  * @return array of errors
  * @throws \Exception
  */
 public static function validateDomDocument(\DOMDocument $dom, $schema, $errorFormat = self::ERROR_FORMAT_DEFAULT)
 {
     if (!function_exists('libxml_set_external_entity_loader')) {
         return [];
     }
     if (!self::$urnResolver) {
         self::$urnResolver = new UrnResolver();
     }
     $schema = self::$urnResolver->getRealPath($schema);
     libxml_use_internal_errors(true);
     libxml_set_external_entity_loader([self::$urnResolver, 'registerEntityLoader']);
     $errors = [];
     try {
         $result = $dom->schemaValidate($schema);
         if (!$result) {
             $errors = self::getXmlErrors($errorFormat);
         }
     } catch (\Exception $exception) {
         libxml_use_internal_errors(false);
         throw $exception;
     }
     libxml_set_external_entity_loader(null);
     libxml_use_internal_errors(false);
     return $errors;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:34,代码来源:Dom.php

示例8: __construct

 /**
  * Build DOM with initial XML contents and specifying identifier attributes for merging
  *
  * Format of $schema: Absolute schema file path or URN
  * Format of $idAttributes: array('name', 'id')
  * Format of $contextXPath: array('/config/ui')
  * The path to ID attribute name should not include any attribute notations or modifiers -- only node names
  *
  * @param UrnResolver $urnResolver
  * @param string $schema Absolute schema file path or URN
  * @param bool $isMergeSimpleXMLElement
  * @param array $contextXPath
  * @param array $idAttributes
  */
 public function __construct(UrnResolver $urnResolver, $schema, $isMergeSimpleXMLElement = false, array $contextXPath = [], array $idAttributes = [])
 {
     $this->schemaFilePath = $urnResolver->getRealPath($schema);
     $this->isMergeSimpleXMLElement = $isMergeSimpleXMLElement;
     $this->contextXPath = $contextXPath;
     $this->idAttributes = $idAttributes;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:21,代码来源:DomMerger.php

示例9: validateDomDocument

 /**
  * Validate dom document
  *
  * @param \DOMDocument $dom
  * @param string $schema Absolute schema file path or URN
  * @param string $errorFormat
  * @return array of errors
  * @throws \Exception
  */
 public static function validateDomDocument(
     \DOMDocument $dom,
     $schema,
     $errorFormat = self::ERROR_FORMAT_DEFAULT
 ) {
     if (!self::$urnResolver) {
         self::$urnResolver = new UrnResolver();
     }
     $schema = self::$urnResolver->getRealPath($schema);
     libxml_use_internal_errors(true);
     libxml_set_external_entity_loader([self::$urnResolver, 'registerEntityLoader']);
     try {
         $result = $dom->schemaValidate($schema);
         $errors = [];
         if (!$result) {
             $validationErrors = libxml_get_errors();
             if (count($validationErrors)) {
                 foreach ($validationErrors as $error) {
                     $errors[] = self::_renderErrorMessage($error, $errorFormat);
                 }
             } else {
                 $errors[] = 'Unknown validation error';
             }
         }
     } catch (\Exception $exception) {
         libxml_use_internal_errors(false);
         throw $exception;
     }
     libxml_set_external_entity_loader(null);
     libxml_use_internal_errors(false);
     return $errors;
 }
开发者ID:nblair,项目名称:magescotch,代码行数:41,代码来源:Dom.php

示例10: testGetSchemaFile

 /**
  * Test schema file exists
  */
 public function testGetSchemaFile()
 {
     $this->_initConfig();
     $this->assertEquals(
         $this->urnResolver->getRealPath('urn:magento:framework:Validator/etc/validation.xsd'),
         $this->_config->getSchemaFile()
     );
     $this->assertFileExists($this->_config->getSchemaFile());
 }
开发者ID:nblair,项目名称:magescotch,代码行数:12,代码来源:ConfigTest.php

示例11: readXsdFiles

 /**
  * Get merged xsd file
  *
  * @param array $fileList
  * @param string $baseXsd
  * @return null|string
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function readXsdFiles($fileList, $baseXsd = null)
 {
     $baseXsd = new \DOMDocument();
     $baseXsdPath = $this->urnResolver->getRealPath($this->searchFilesPattern . $this->fileName);
     $baseXsd->load($baseXsdPath);
     $configMerge = null;
     foreach ($fileList as $key => $content) {
         if ($key == $baseXsdPath) {
             continue;
         }
         try {
             if (!empty($content)) {
                 if ($configMerge) {
                     $configMerge = $this->mergeXsd($configMerge, $content);
                 } else {
                     $configMerge = $this->mergeXsd($baseXsd->saveXML(), $content);
                 }
             }
         } catch (\Magento\Framework\Config\Dom\ValidationException $e) {
             throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase("Invalid XSD in file %1:\n%2", [$key, $e->getMessage()]));
         }
     }
     return $configMerge;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:32,代码来源:Reader.php

示例12: getSchema

 /**
  * Get path to merged config schema
  *
  * @return string|null
  */
 public function getSchema()
 {
     return $this->urnResolver->getRealPath('urn:magento:framework:Cache/etc/cache.xsd');
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:9,代码来源:SchemaLocator.php

示例13: testGetPerFileSchema

 public function testGetPerFileSchema()
 {
     $this->assertEquals($this->urnResolver->getRealPath('urn:magento:framework:Api/etc/extension_attributes.xsd'), $this->model->getPerFileSchema());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:4,代码来源:SchemaLocatorTest.php

示例14: __construct

 /**
  * Initialize dependencies.
  *
  * @param \Magento\Framework\Config\Dom\UrnResolver $urnResolver
  */
 public function __construct(\Magento\Framework\Config\Dom\UrnResolver $urnResolver)
 {
     $this->schema = $urnResolver->getRealPath('urn:magento:framework:Communication/etc/communication.xsd');
     $this->perFileSchema = $urnResolver->getRealPath('urn:magento:framework:Communication/etc/communication.xsd');
 }
开发者ID:rahulkumars,项目名称:magento2,代码行数:10,代码来源:SchemaLocator.php

示例15: getPerFileSchema

 /**
  * Get path to pre file validation schema
  *
  * @return null
  */
 public function getPerFileSchema()
 {
     return $this->urnResolver->getRealPath('urn:magento:framework:Search/etc/search_request.xsd');
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:SchemaLocator.php


注:本文中的Magento\Framework\Config\Dom\UrnResolver::getRealPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。