本文整理汇总了PHP中Magento\Framework\Component\ComponentRegistrar::getPaths方法的典型用法代码示例。如果您正苦于以下问题:PHP ComponentRegistrar::getPaths方法的具体用法?PHP ComponentRegistrar::getPaths怎么用?PHP ComponentRegistrar::getPaths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Component\ComponentRegistrar
的用法示例。
在下文中一共展示了ComponentRegistrar::getPaths方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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)$/');
}
示例2: testGetPathsForModule
public function testGetPathsForModule()
{
ComponentRegistrar::register(ComponentRegistrar::MODULE, "test_module_one", "some/path/name/one");
ComponentRegistrar::register(ComponentRegistrar::MODULE, "test_module_two", "some/path/name/two");
$expected = ['test_module_one' => "some/path/name/one", 'test_module_two' => "some/path/name/two"];
$this->assertContains($expected['test_module_one'], $this->object->getPaths(ComponentRegistrar::MODULE));
$this->assertContains($expected['test_module_two'], $this->object->getPaths(ComponentRegistrar::MODULE));
}
示例3: __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();
}
示例4: getComponentName
/**
* Try to get component name by path, return false if not found
*
* @param string $componentType
* @param string $path
* @return bool|string
*/
private function getComponentName($componentType, $path)
{
foreach ($this->componentRegistrar->getPaths($componentType) as $componentName => $componentDir) {
$componentDir .= '/';
if (strpos($path, $componentDir) !== false) {
return $componentName;
}
}
return false;
}
示例5: getSuggestsFromModules
/**
* Retrieve suggested sample data packages from modules composer.json
*
* @return array
*/
protected function getSuggestsFromModules()
{
$suggests = [];
foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $moduleDir) {
$file = $moduleDir . '/composer.json';
/** @var Package $package */
$package = $this->getModuleComposerPackage($file);
$suggest = json_decode(json_encode($package->get('suggest')), true);
if (!empty($suggest)) {
$suggests += $suggest;
}
}
return $suggests;
}
示例6: setUp
public function setUp()
{
$componentRegistrar = new ComponentRegistrar();
$dirSearch = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Component\\DirSearch');
$themePackageList = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\View\\Design\\Theme\\ThemePackageList');
$this->model = new Files($componentRegistrar, $dirSearch, $themePackageList);
foreach ($componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $moduleDir) {
$this->moduleTests[] = '#' . $moduleDir . '/Test#';
}
foreach ($componentRegistrar->getPaths(ComponentRegistrar::LIBRARY) as $libraryDir) {
$this->libTests[] = '#' . $libraryDir . '/Test#';
$this->frameworkTests[] = '#' . $libraryDir . '/[\\w]+/Test#';
}
}
示例7: 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;
}
}
}
}
示例8: getLocalePlacePath
/**
* @return array
*/
public function getLocalePlacePath()
{
$pathToSource = BP;
$places = [];
$componentRegistrar = new ComponentRegistrar();
foreach ($componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $modulePath) {
$places[basename($modulePath)] = ['placePath' => $modulePath];
}
foreach ($componentRegistrar->getPaths(ComponentRegistrar::THEME) as $themePath) {
$placeName = basename(dirname(dirname($themePath))) . '_' . basename($themePath);
$places[$placeName] = ['placePath' => $themePath];
}
$places['lib_web'] = ['placePath' => "{$pathToSource}/lib/web"];
return $places;
}
示例9: __construct
/**
* Constructor
*/
public function __construct()
{
$componentRegistrar = new ComponentRegistrar();
/** @var \Magento\Framework\Filesystem $filesystem */
foreach ($componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $moduleDir) {
$key = $moduleDir . '/';
$value = $key . 'Test/Unit/';
self::$_cleanableFolders[$key] = [$value];
}
foreach ($componentRegistrar->getPaths(ComponentRegistrar::LIBRARY) as $libraryDir) {
$key = $libraryDir . '/';
$valueRootFolder = $key . '/Test/Unit/';
$valueSubFolder = $key . '/*/Test/Unit/';
self::$_cleanableFolders[$key] = [$valueSubFolder, $valueRootFolder];
}
}
示例10: testLocalXmlFilesAbsent
public function testLocalXmlFilesAbsent()
{
$componentRegistrar = new ComponentRegistrar();
foreach ($componentRegistrar->getPaths(ComponentRegistrar::THEME) as $themeDir) {
$this->assertEmpty(glob($themeDir . '/local.xml'));
}
}
示例11: 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));
}
}
示例12: testCheckDependencies
public function testCheckDependencies()
{
$invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
$invoker(function ($file) {
$componentRegistrar = new ComponentRegistrar();
$fileReflection = new FileReflection($file);
$tokens = new Tokens($fileReflection->getContents(), new ParserFactory());
$tokens->parseContent();
$dependencies = array_merge((new Injectable())->getDependencies($fileReflection), $tokens->getDependencies());
$pattern = '#^(\\\\|)' . implode('|', $this->getForbiddenNamespaces()) . '\\\\#';
foreach ($dependencies as $dependency) {
$dependencyPaths = explode('/', $dependency);
$dependencyPaths = array_slice($dependencyPaths, 2);
$dependency = implode('\\', $dependencyPaths);
$libraryPaths = $componentRegistrar->getPaths(ComponentRegistrar::LIBRARY);
foreach ($libraryPaths as $libraryPath) {
$filePath = str_replace('\\', '/', $libraryPath . '/' . $dependency . '.php');
if (preg_match($pattern, $dependency) && !file_exists($filePath)) {
$this->errors[$fileReflection->getFileName()][] = $dependency;
}
}
}
if (!empty($this->errors)) {
$this->fail($this->getFailMessage());
}
}, $this->libraryDataProvider());
}
示例13: 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));
}
}
}
示例14: getComponentDirectories
/**
* Get the given type component directories
*
* @param string $componentType
* @return array
*/
private function getComponentDirectories($componentType)
{
$dirs = [];
foreach ($this->componentRegistrar->getPaths($componentType) as $componentDir) {
$dirs[] = $componentDir . '/';
}
return $dirs;
}
示例15: getXmlFiles
public function getXmlFiles()
{
$componentRegistrar = new ComponentRegistrar();
$codeXml = [];
foreach ($componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $modulePath) {
$codeXml = array_merge($codeXml, $this->_getFiles($modulePath, '*.xml', '/.\\/Test\\/Unit\\/./'));
}
$this->_filterSpecialCases($codeXml);
$designXml = [];
foreach ($componentRegistrar->getPaths(ComponentRegistrar::THEME) as $themePath) {
$designXml = array_merge($designXml, $this->_getFiles($themePath, '*.xml'));
}
$libXml = [];
foreach ($componentRegistrar->getPaths(ComponentRegistrar::LIBRARY) as $libraryPath) {
$libXml = array_merge($libXml, $this->_getFiles($libraryPath, '*.xml', '/.\\/Test\\/./'));
}
return $this->_dataSet(array_merge($codeXml, $designXml, $libXml));
}