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


PHP Component\ComponentRegistrar类代码示例

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


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

示例1: 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

示例2: 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

示例3: testRouteConfigsValidation

 public function testRouteConfigsValidation()
 {
     $invalidFiles = [];
     $componentRegistrar = new ComponentRegistrar();
     $files = [];
     foreach ($componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $moduleDir) {
         $mask = $moduleDir . '/etc/*/routes.xml';
         $files = array_merge($files, glob($mask));
     }
     $mergedConfig = new \Magento\Framework\Config\Dom('<config></config>', $this->_idAttributes);
     foreach ($files as $file) {
         $content = file_get_contents($file);
         try {
             new \Magento\Framework\Config\Dom($content, $this->_idAttributes, null, $this->schemaFile);
             //merge won't be performed if file is invalid because of exception thrown
             $mergedConfig->merge($content);
         } catch (\Magento\Framework\Config\Dom\ValidationException $e) {
             $invalidFiles[] = $file;
         }
     }
     if (!empty($invalidFiles)) {
         $this->fail('Found broken files: ' . implode("\n", $invalidFiles));
     }
     try {
         $errors = [];
         $mergedConfig->validate($this->mergedSchemaFile, $errors);
     } catch (\Exception $e) {
         $this->fail('Merged routes config is invalid: ' . "\n" . implode("\n", $errors));
     }
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:30,代码来源:RouteConfigFilesTest.php

示例4: testCircularDependencies

 /**
  * Test circular dependencies between languages
  */
 public function testCircularDependencies()
 {
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $componentRegistrar = new ComponentRegistrar();
     $declaredLanguages = $componentRegistrar->getPaths(ComponentRegistrar::LANGUAGE);
     $validationStateMock = $this->getMock('\\Magento\\Framework\\Config\\ValidationStateInterface', [], [], '', false);
     $validationStateMock->method('isValidationRequired')->willReturn(true);
     $domFactoryMock = $this->getMock('Magento\\Framework\\Config\\DomFactory', [], [], '', false);
     $domFactoryMock->expects($this->any())->method('createDom')->willReturnCallback(function ($arguments) use($validationStateMock) {
         return new \Magento\Framework\Config\Dom($arguments['xml'], $validationStateMock, [], null, $arguments['schemaFile']);
     });
     $packs = [];
     foreach ($declaredLanguages as $language) {
         $languageConfig = $objectManager->getObject('Magento\\Framework\\App\\Language\\Config', ['source' => file_get_contents($language . '/language.xml'), 'domFactory' => $domFactoryMock]);
         $this->packs[$languageConfig->getVendor()][$languageConfig->getPackage()] = $languageConfig;
         $packs[] = $languageConfig;
     }
     /** @var $languageConfig Config */
     foreach ($packs as $languageConfig) {
         $languages = [];
         /** @var $config Config */
         foreach ($this->collectCircularInheritance($languageConfig) as $config) {
             $languages[] = $config->getVendor() . '/' . $config->getPackage();
         }
         if (!empty($languages)) {
             $this->fail("Circular dependency detected:\n" . implode(' -> ', $languages));
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:32,代码来源:CircularDependencyTest.php

示例5: _getFiles

 /**
  * @return \RegexIterator
  */
 protected function _getFiles()
 {
     $filesCollector = new FilesCollector();
     $componentRegistrar = new ComponentRegistrar();
     $paths = array_merge($componentRegistrar->getPaths(ComponentRegistrar::MODULE), $componentRegistrar->getPaths(ComponentRegistrar::LIBRARY));
     return $filesCollector->getFiles($paths, '/\\.(php|phtml)$/');
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:AbstractTestCase.php

示例6: 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

示例7: testLocalXmlFilesAbsent

 public function testLocalXmlFilesAbsent()
 {
     $componentRegistrar = new ComponentRegistrar();
     foreach ($componentRegistrar->getPaths(ComponentRegistrar::THEME) as $themeDir) {
         $this->assertEmpty(glob($themeDir . '/local.xml'));
     }
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:7,代码来源:ObsoleteThemeLocalXmlTest.php

示例8: __construct

 /**
  * Class constructor
  *
  * @param \Magento\Framework\Filesystem $filesystem
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface
  * @param ComponentRegistrar $componentRegistrar
  * @param string|null $scope
  */
 public function __construct(\Magento\Framework\Filesystem $filesystem, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface, ComponentRegistrar $componentRegistrar, $scope = null)
 {
     $this->_filesystem = $filesystem;
     $this->_isAllowSymlinks = $scopeConfigInterface->getValue(self::XML_PATH_TEMPLATE_ALLOW_SYMLINK, $scope);
     $this->_themesDir = $componentRegistrar->getPaths(ComponentRegistrar::THEME);
     $this->moduleDirs = $componentRegistrar->getPaths(ComponentRegistrar::MODULE);
     $this->_compiledDir = $this->_filesystem->getDirectoryRead(DirectoryList::TEMPLATE_MINIFICATION_DIR)->getAbsolutePath();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:Validator.php

示例9: 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

示例10: 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

示例11: setUp

    public function setUp()
    {
        $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false);
        $objectManagerProvider = $this->getMock(
            'Magento\Setup\Model\ObjectManagerProvider',
            [],
            [],
            '',
            false
        );
        $this->objectManager = $this->getMockForAbstractClass(
            'Magento\Framework\ObjectManagerInterface',
            [],
            '',
            false
        );
        $this->cacheMock = $this->getMockBuilder('Magento\Framework\App\Cache')
            ->disableOriginalConstructor()
            ->getMock();

        $objectManagerProvider->expects($this->once())
            ->method('get')
            ->willReturn($this->objectManager);
        $this->manager = $this->getMock('Magento\Setup\Module\Di\App\Task\Manager', [], [], '', false);
        $this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false);
        $this->filesystem = $this->getMockBuilder('Magento\Framework\Filesystem')
            ->disableOriginalConstructor()
            ->getMock();

        $this->fileDriver = $this->getMockBuilder('Magento\Framework\Filesystem\Driver\File')
            ->disableOriginalConstructor()
            ->getMock();
        $this->componentRegistrar = $this->getMock(
            '\Magento\Framework\Component\ComponentRegistrar',
            [],
            [],
            '',
            false
        );
        $this->componentRegistrar->expects($this->any())->method('getPaths')->willReturnMap([
            [ComponentRegistrar::MODULE, ['/path/to/module/one', '/path/to/module/two']],
            [ComponentRegistrar::LIBRARY, ['/path/to/library/one', '/path/to/library/two']],
        ]);

        $this->command = new DiCompileCommand(
            $this->deploymentConfig,
            $this->directoryList,
            $this->manager,
            $objectManagerProvider,
            $this->filesystem,
            $this->fileDriver,
            $this->componentRegistrar
        );
    }
开发者ID:rafaelstz,项目名称:magento2,代码行数:54,代码来源:DiCompileCommandTest.php

示例12: setUp

 public function setUp()
 {
     $this->componentRegistrar = $this->getMock('Magento\\Framework\\Component\\ComponentRegistrar', [], [], '', false);
     $this->reader = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', [], [], '', false);
     $this->componentRegistrar->expects($this->once())->method('getPaths')->will($this->returnValue(['A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'E' => 'E']));
     $composerData = ['A/composer.json' => '{"name":"a", "require":{"b":"0.1"}, "conflict":{"c":"0.1"}, "version":"0.1"}', 'B/composer.json' => '{"name":"b", "require":{"d":"0.3"}, "version":"0.2"}', 'C/composer.json' => '{"name":"c", "require":{"e":"0.1"}, "version":"0.1"}', 'D/composer.json' => '{"name":"d", "conflict":{"c":"0.1"}, "version":"0.3"}', 'E/composer.json' => '{"name":"e", "version":"0.4"}'];
     $fileIteratorMock = $this->getMock('Magento\\Framework\\Config\\FileIterator', [], [], '', false);
     $fileIteratorMock->expects($this->once())->method('toArray')->will($this->returnValue($composerData));
     $this->reader->expects($this->once())->method('getComposerJsonFiles')->will($this->returnValue($fileIteratorMock));
     $this->packageInfo = new PackageInfo($this->reader, $this->componentRegistrar);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:PackageInfoTest.php

示例13: setUp

 /**
  * Test Setup
  *
  * @return void
  */
 public function setUp()
 {
     $this->_fileSystemMock = $this->getMock('\\Magento\\Framework\\Filesystem', [], [], '', false);
     $this->_scopeConfigMock = $this->getMock('\\Magento\\Framework\\App\\Config\\ScopeConfigInterface');
     $this->rootDirectoryMock = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface');
     $this->compiledDirectoryMock = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface');
     $this->_fileSystemMock->expects($this->any())->method('getDirectoryRead')->will($this->returnValueMap([[DirectoryList::ROOT, DriverPool::FILE, $this->rootDirectoryMock], [DirectoryList::TEMPLATE_MINIFICATION_DIR, DriverPool::FILE, $this->compiledDirectoryMock]]));
     $this->compiledDirectoryMock->expects($this->any())->method('getAbsolutePath')->will($this->returnValue('/magento/var/compiled'));
     $this->componentRegistrar = $this->getMock('Magento\\Framework\\Component\\ComponentRegistrar', [], [], '', false);
     $this->componentRegistrar->expects($this->any())->method('getPaths')->will($this->returnValueMap([[ComponentRegistrar::MODULE, ['/magento/app/code/Some/Module']], [ComponentRegistrar::THEME, ['/magento/themes/default']]]));
     $this->_validator = new \Magento\Framework\View\Element\Template\File\Validator($this->_fileSystemMock, $this->_scopeConfigMock, $this->componentRegistrar);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:ValidatorTest.php

示例14: initializeMap

 /**
  * Initialize package name to full theme path map
  *
  * @return void
  * @throws \Zend_Json_Exception
  */
 private function initializeMap()
 {
     $themePaths = $this->componentRegistrar->getPaths(ComponentRegistrar::THEME);
     /** @var \Magento\Theme\Model\Theme $theme */
     foreach ($themePaths as $fullThemePath => $themeDir) {
         $themeDirRead = $this->readDirFactory->create($themeDir);
         if ($themeDirRead->isExist('composer.json')) {
             $rawData = \Zend_Json::decode($themeDirRead->readFile('composer.json'));
             if (isset($rawData['name'])) {
                 $this->packageNameToFullPathMap[$rawData['name']] = $fullThemePath;
             }
         }
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:ThemePackageInfo.php

示例15: 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


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