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


PHP ComponentRegistrar::getPath方法代码示例

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


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

示例1: getRealPath

 /**
  * Get real file path by it's URN reference
  *
  * @param string $schema
  * @return string
  * @throws NotFoundException
  */
 public function getRealPath($schema)
 {
     if (strpos($schema, 'urn:') !== 0) {
         return $schema;
     }
     $componentRegistrar = new ComponentRegistrar();
     $matches = [];
     $modulePattern = '/urn:(?<vendor>([a-zA-Z]*)):module:(?<module>([A-Za-z\\_]*)):(?<path>(.+))/';
     $frameworkPattern = '/urn:(?<vendor>([a-zA-Z]*)):(?<framework>(framework[A-Za-z\\-]*)):(?<path>(.+))/';
     if (preg_match($modulePattern, $schema, $matches)) {
         //urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd
         $package = $componentRegistrar->getPath(ComponentRegistrar::MODULE, $matches['module']);
     } else {
         if (preg_match($frameworkPattern, $schema, $matches)) {
             //urn:magento:framework:Module/etc/module.xsd
             //urn:magento:framework-amqp:Module/etc/module.xsd
             $package = $componentRegistrar->getPath(ComponentRegistrar::LIBRARY, $matches['vendor'] . '/' . $matches['framework']);
         } else {
             throw new NotFoundException(new Phrase("Unsupported format of schema location: '%1'", [$schema]));
         }
     }
     $schemaPath = $package . '/' . $matches['path'];
     if (empty($package) || !file_exists($schemaPath)) {
         throw new NotFoundException(new Phrase("Could not locate schema: '%1' at '%2'", [$schema, $schemaPath]));
     }
     return $schemaPath;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:34,代码来源:UrnResolver.php

示例2: assertFixturesRegistered

 private function assertFixturesRegistered()
 {
     $this->assertSame(__DIR__ . '/_files/components/b', $this->componentRegistrar->getPath(ComponentRegistrar::LIBRARY, self::LIBRARY_NAME));
     $this->assertSame(__DIR__ . '/_files/components', $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, self::MODULE_NAME));
     $this->assertSame(__DIR__ . '/_files/components/a/aa/aaa', $this->componentRegistrar->getPath(ComponentRegistrar::THEME, self::THEME_NAME));
     $this->assertSame(__DIR__ . '/_files/components/a/aa', $this->componentRegistrar->getPath(ComponentRegistrar::LANGUAGE, self::LANGUAGE_NAME));
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:7,代码来源:ComponentRegistrarFixtureTest.php

示例3: getRealPath

 /**
  * Get real file path by it's URN reference
  *
  * @param string $schema
  * @return string
  * @throws \UnexpectedValueException
  */
 public function getRealPath($schema)
 {
     $componentRegistrar = new ComponentRegistrar();
     if (substr($schema, 0, 4) == 'urn:') {
         // resolve schema location
         $urnParts = explode(':', $schema);
         if ($urnParts[2] == 'module') {
             // urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd
             // 0 : urn, 1: magento, 2: module, 3: Magento_Catalog, 4: etc/catalog_attributes.xsd
             // moduleName -> Magento_Catalog
             $schemaPath = $componentRegistrar->getPath(ComponentRegistrar::MODULE, $urnParts[3]) . '/' . $urnParts[4];
         } else {
             if (strpos($urnParts[2], 'framework') === 0) {
                 // urn:magento:framework:Module/etc/module.xsd
                 // 0: urn, 1: magento, 2: framework, 3: Module/etc/module.xsd
                 // libaryName -> magento/framework
                 $libraryName = $urnParts[1] . '/' . $urnParts[2];
                 $schemaPath = $componentRegistrar->getPath(ComponentRegistrar::LIBRARY, $libraryName) . '/' . $urnParts[3];
             } else {
                 throw new \UnexpectedValueException("Unsupported format of schema location: " . $schema);
             }
         }
         if (!empty($schemaPath) && file_exists($schemaPath)) {
             $schema = $schemaPath;
         } else {
             throw new \UnexpectedValueException("Could not locate schema: '" . $schema . "' at '" . $schemaPath . "'");
         }
     }
     return $schema;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:37,代码来源:UrnResolver.php

示例4: install

 /**
  * @inheritdoc
  */
 public function install()
 {
     $this->eavConfig->clear();
     $importModel = $this->importModel;
     $importModel->setData(['entity' => 'catalog_product', 'behavior' => 'append', 'import_images_file_dir' => 'pub/media/catalog/product', Import::FIELD_NAME_VALIDATION_STRATEGY => ProcessingErrorAggregatorInterface::VALIDATION_STRATEGY_SKIP_ERRORS]);
     $source = $this->csvSourceFactory->create(['file' => 'fixtures/products.csv', 'directory' => $this->readFactory->create($this->componentRegistrar->getPath(ComponentRegistrar::MODULE, 'Magento_ConfigurableSampleData'))]);
     $currentPath = getcwd();
     chdir(BP);
     $importModel->validateSource($source);
     $importModel->importSource();
     chdir($currentPath);
     $this->eavConfig->clear();
     $this->reindex();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:Product.php

示例5: getPackageName

 /**
  * Get package name of a theme by its full theme path
  *
  * @param string $themePath
  * @return string
  * @throws \Zend_Json_Exception
  */
 public function getPackageName($themePath)
 {
     $themePath = $this->componentRegistrar->getPath(ComponentRegistrar::THEME, $themePath);
     $themeDir = $this->readDirFactory->create($themePath);
     if ($themeDir->isExist('composer.json')) {
         $rawData = [];
         $themeFile = $themeDir->readFile('composer.json');
         if ($themeFile) {
             $rawData = \Zend_Json::decode($themeFile);
         }
         return isset($rawData['name']) ? $rawData['name'] : '';
     }
     return '';
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:21,代码来源:ThemePackageInfo.php

示例6: isModuleExists

 /**
  * Check module existence
  *
  * @param string $moduleName
  * @return bool
  */
 public function isModuleExists($moduleName)
 {
     $key = __METHOD__ . "/{$moduleName}";
     if (!isset(self::$_cache[$key])) {
         self::$_cache[$key] = file_exists($this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName));
     }
     return self::$_cache[$key];
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:Files.php

示例7: testGetRealPathWithModuleUrn

 public function testGetRealPathWithModuleUrn()
 {
     $xsdUrn = 'urn:magento:module:Magento_Customer:etc/address_formats.xsd';
     $componentRegistrar = new ComponentRegistrar();
     $xsdPath = $componentRegistrar->getPath(ComponentRegistrar::MODULE, 'Magento_Customer') . '/etc/address_formats.xsd';
     $result = $this->urnResolver->getRealPath($xsdUrn);
     $this->assertSame($xsdPath, $result, 'XSD paths does not match.');
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:8,代码来源:UrnResolverTest.php

示例8: getBlackList

 /**
  * @return array
  */
 protected function getBlackList()
 {
     $blackListFiles = [];
     $componentRegistrar = new ComponentRegistrar();
     foreach ($this->getFilesData('blacklist/files_list*') as $fileInfo) {
         $blackListFiles[] = $componentRegistrar->getPath(ComponentRegistrar::MODULE, $fileInfo[0]) . DIRECTORY_SEPARATOR . $fileInfo[1];
     }
     return $blackListFiles;
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:12,代码来源:ObsoleteResponseTest.php

示例9: execute

 /**
  * Download sample file action
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $fileName = $this->getRequest()->getParam('filename') . '.csv';
     $moduleDir = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, self::SAMPLE_FILES_MODULE);
     $fileAbsolutePath = $moduleDir . '/Files/Sample/' . $fileName;
     $directoryRead = $this->readFactory->create($moduleDir);
     $filePath = $directoryRead->getRelativePath($fileAbsolutePath);
     if (!$directoryRead->isFile($filePath)) {
         /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
         $this->messageManager->addError(__('There is no sample file for this entity.'));
         $resultRedirect = $this->resultRedirectFactory->create();
         $resultRedirect->setPath('*/import');
         return $resultRedirect;
     }
     $fileSize = isset($directoryRead->stat($filePath)['size']) ? $directoryRead->stat($filePath)['size'] : null;
     $this->fileFactory->create($fileName, null, DirectoryList::VAR_DIR, 'application/octet-stream', $fileSize);
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     $resultRaw->setContents($directoryRead->readFile($filePath));
     return $resultRaw;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:26,代码来源:Download.php

示例10: _getLocalePatternDir

 /**
  * Return pattern for theme locale directories, where <locale_placeholder> is placed to mark a locale's location.
  *
  * @param \Magento\Framework\View\Design\ThemeInterface $theme
  * @return string
  * @throws \Exception
  */
 protected static function _getLocalePatternDir(\Magento\Framework\View\Design\ThemeInterface $theme)
 {
     $localePlaceholder = '<locale_placeholder>';
     $params = ['area' => $theme->getArea(), 'theme' => $theme, 'locale' => $localePlaceholder];
     $patternDirs = self::$_fallbackRule->getPatternDirs($params);
     $themePath = self::$_componentRegistrar->getPath(\Magento\Framework\Component\ComponentRegistrar::THEME, $theme->getFullPath());
     foreach ($patternDirs as $patternDir) {
         $patternPath = $patternDir . '/';
         if (strpos($patternPath, $themePath) !== false && strpos($patternPath, $localePlaceholder) !== false) {
             return $patternDir;
         }
     }
     throw new \Exception('Unable to determine theme locale path');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:21,代码来源:ViewFileReferenceTest.php

示例11: testLayoutFile

 public function testLayoutFile()
 {
     $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
     $invoker(function ($layoutFile) {
         $layoutXml = simplexml_load_file($layoutFile);
         $this->_testObsoleteReferences($layoutXml);
         $this->_testObsoleteAttributes($layoutXml);
         $selectorHeadBlock = '(name()="block" or name()="referenceBlock") and ' . '(@name="head" or @name="convert_root_head" or @name="vde_head")';
         $this->assertSame([], $layoutXml->xpath('//block[@class="Magento\\Theme\\Block\\Html\\Head\\Css" ' . 'or @class="Magento\\Theme\\Block\\Html\\Head\\Link" ' . 'or @class="Magento\\Theme\\Block\\Html\\Head\\Script"]' . '/parent::*[not(' . $selectorHeadBlock . ')]'), 'Blocks \\Magento\\Theme\\Block\\Html\\Head\\{Css,Link,Script} ' . 'are allowed within the "head" block only. ' . 'Verify integrity of the nodes nesting.');
         $this->assertSame([], $layoutXml->xpath('/layout//*[@output="toHtml"]'), 'output="toHtml" is obsolete. Use output="1"');
         foreach ($layoutXml as $handle) {
             $this->assertNotContains((string) $handle['id'], $this->_obsoleteNodes, 'This layout handle is obsolete.');
         }
         foreach ($layoutXml->xpath('@helper') as $action) {
             $this->assertNotContains('/', $action->getAttribute('helper'));
             $this->assertContains('::', $action->getAttribute('helper'));
         }
         $componentRegistrar = new ComponentRegistrar();
         if (false !== strpos($layoutFile, $componentRegistrar->getPath(ComponentRegistrar::MODULE, 'Magento_Sales') . '/view/adminhtml/layout/sales_order') || false !== strpos($layoutFile, $componentRegistrar->getPath(ComponentRegistrar::MODULE, 'Magento_Shipping') . '/view/adminhtml/layout/adminhtml_order')) {
             $this->markTestIncomplete("The file {$layoutFile} has to use \\Magento\\Core\\Block\\Text\\List, \n" . 'there is no solution to get rid of it right now.');
         }
         $this->assertSame([], $layoutXml->xpath('/layout//block[@class="Magento\\Framework\\View\\Element\\Text\\ListText"]'), 'The class \\Magento\\Framework\\View\\Element\\Text\\ListTest' . ' is not supposed to be used in layout anymore.');
     }, \Magento\Framework\App\Utility\Files::init()->getLayoutFiles());
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:24,代码来源:LayoutTest.php

示例12: buildPathToLocaleDirectoryByContext

 /**
  * Get paths by context
  *
  * @param string $type
  * @param array $value
  * @return string
  * @throws \InvalidArgumentException
  */
 public function buildPathToLocaleDirectoryByContext($type, $value)
 {
     switch ($type) {
         case self::CONTEXT_TYPE_MODULE:
             $path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $value);
             break;
         case self::CONTEXT_TYPE_THEME:
             $path = $this->componentRegistrar->getPath(ComponentRegistrar::THEME, $value);
             break;
         case self::CONTEXT_TYPE_LIB:
             $path = BP . '/lib/web';
             break;
         default:
             throw new \InvalidArgumentException(sprintf('Invalid context given: "%s".', $type));
     }
     return $path . '/' . self::LOCALE_DIRECTORY . '/';
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:25,代码来源:Context.php

示例13: prepareMenuConfig

 /**
  * @return \Magento\Backend\Model\Menu\Config
  */
 protected function prepareMenuConfig()
 {
     $this->loginAdminUser();
     $componentRegistrar = new \Magento\Framework\Component\ComponentRegistrar();
     $libraryPath = $componentRegistrar->getPath(ComponentRegistrar::LIBRARY, 'magento/framework');
     $reflection = new \ReflectionClass('Magento\\Framework\\Component\\ComponentRegistrar');
     $paths = $reflection->getProperty('paths');
     $paths->setAccessible(true);
     $paths->setValue([ComponentRegistrar::MODULE => [], ComponentRegistrar::THEME => [], ComponentRegistrar::LANGUAGE => [], ComponentRegistrar::LIBRARY => []]);
     $paths->setAccessible(false);
     ComponentRegistrar::register(ComponentRegistrar::LIBRARY, 'magento/framework', $libraryPath);
     ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_Backend', __DIR__ . '/_files/menu/Magento/Backend');
     /* @var $validationState \Magento\Framework\App\Arguments\ValidationState */
     $validationState = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\App\\Arguments\\ValidationState', ['appMode' => State::MODE_DEFAULT]);
     /* @var $configReader \Magento\Backend\Model\Menu\Config\Reader */
     $configReader = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Backend\\Model\\Menu\\Config\\Reader', ['validationState' => $validationState]);
     return \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Backend\\Model\\Menu\\Config', ['configReader' => $configReader, 'configCacheType' => $this->configCacheType]);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:21,代码来源:MenuTest.php

示例14: get

 /**
  * {@inheritdoc}
  */
 public function get($filename, $scope)
 {
     switch ($scope) {
         case 'global':
             $iterator = $this->moduleReader->getConfigurationFiles($filename)->toArray();
             $themeConfigFile = $this->currentTheme->getCustomization()->getCustomViewConfigPath();
             if ($themeConfigFile
                 && $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))
             ) {
                 $iterator[$this->rootDirectory->getRelativePath($themeConfigFile)] =
                     $this->rootDirectory->readFile(
                         $this->rootDirectory->getRelativePath(
                             $themeConfigFile
                         )
                     );
             } else {
                 $designPath =
                     $this->componentRegistrar->getPath(
                         ComponentRegistrar::THEME,
                         $this->area . '/' . $this->themePath
                     ) . '/etc/view.xml';
                 if (file_exists($designPath)) {
                     try {
                         $designDom = new \DOMDocument;
                         $designDom->load($designPath);
                         $iterator[$designPath] = $designDom->saveXML();
                     } catch (\Exception $e) {
                         throw new \Magento\Framework\Exception\LocalizedException(
                             new \Magento\Framework\Phrase('Could not read config file')
                         );
                     }
                 }
             }
             break;
         default:
             $iterator = $this->iteratorFactory->create([]);
             break;
     }
     return $iterator;
 }
开发者ID:razbakov,项目名称:magento2,代码行数:43,代码来源:FileResolver.php

示例15: _extractWhitelist

 /**
  * Extract whitelisted entries and words from configuration xml
  *
  * @param \SimpleXMLElement $configXml
  * @return \Magento\TestFramework\Inspection\WordsFinder
  * @throws \Magento\TestFramework\Inspection\Exception
  */
 protected function _extractWhitelist(\SimpleXMLElement $configXml)
 {
     // Load whitelist entries
     $whitelist = [];
     $nodes = $configXml->xpath('//config/whitelist/item');
     foreach ($nodes as $node) {
         $path = $node->xpath('path');
         if (!$path) {
             throw new \Magento\TestFramework\Inspection\Exception('A "path" must be defined for the whitelisted item');
         }
         $component = $node->xpath('component');
         if ($component) {
             $componentType = $component[0]->xpath('@type')[0];
             $componentName = $component[0]->xpath('@name')[0];
             $path = $this->componentRegistrar->getPath((string) $componentType, (string) $componentName) . '/' . (string) $path[0];
         } else {
             $path = $this->_baseDir . '/' . (string) $path[0];
         }
         // Words
         $words = [];
         $wordNodes = $node->xpath('word');
         if ($wordNodes) {
             foreach ($wordNodes as $wordNode) {
                 $words[] = (string) $wordNode;
             }
         }
         $whitelist[$path] = $words;
     }
     // Merge with already present whitelist
     foreach ($whitelist as $newPath => $newWords) {
         if (isset($this->_whitelist[$newPath])) {
             $newWords = array_merge($this->_whitelist[$newPath], $newWords);
         }
         $this->_whitelist[$newPath] = array_unique($newWords);
     }
     return $this;
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:44,代码来源:WordsFinder.php


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