本文整理汇总了PHP中Magento\Framework\App\Filesystem\DirectoryList::getRoot方法的典型用法代码示例。如果您正苦于以下问题:PHP DirectoryList::getRoot方法的具体用法?PHP DirectoryList::getRoot怎么用?PHP DirectoryList::getRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Filesystem\DirectoryList
的用法示例。
在下文中一共展示了DirectoryList::getRoot方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove
/**
* Run 'composer remove'
*
* @param array $packages
* @return void
*/
public function remove(array $packages)
{
$this->composerApp->resetComposer();
$this->composerApp->setAutoExit(false);
$vendor = (include $this->directoryList->getPath(DirectoryList::CONFIG) . '/vendor_path.php');
$this->composerApp->run(new ArrayInput(['command' => 'remove', 'packages' => $packages, '--working-dir' => $this->directoryList->getRoot() . '/' . $vendor . '/..']));
}
示例2: setUp
public function setUp()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/** @var \Magento\Framework\App\Filesystem $filesystem */
$filesystem = $objectManager->create('Magento\\Framework\\App\\Filesystem', array('directoryList' => $objectManager->create('Magento\\Framework\\App\\Filesystem\\DirectoryList', array('root' => BP, 'directories' => array(\Magento\Framework\App\Filesystem::MODULES_DIR => array('path' => __DIR__ . '/_files/code'), \Magento\Framework\App\Filesystem::THEMES_DIR => array('path' => __DIR__ . '/_files/design'), \Magento\Framework\App\Filesystem::CONFIG_DIR => array('path' => __DIR__ . '/_files/'))))));
$moduleListMock = $this->getMockBuilder('Magento\\Framework\\Module\\ModuleListInterface')->disableOriginalConstructor()->getMock();
$moduleListMock->expects($this->any())->method('getModules')->will($this->returnValue(array('Magento_Test' => array('name' => 'Magento_Test', 'version' => '1.11.1', 'active' => 'true'))));
$moduleReader = $objectManager->create('Magento\\Framework\\Module\\Dir\\Reader', array('moduleList' => $moduleListMock, 'filesystem' => $filesystem));
$moduleReader->setModuleDir('Magento_Test', 'etc', __DIR__ . '/_files/code/Magento/Test/etc');
$this->_object = $objectManager->create('Magento\\Widget\\Model\\Config\\FileResolver', array('moduleReader' => $moduleReader, 'filesystem' => $filesystem));
$this->directoryList = $objectManager->get('Magento\\Framework\\App\\Filesystem\\DirectoryList');
$dirPath = ltrim(str_replace($this->directoryList->getRoot(), '', str_replace('\\', '/', __DIR__)) . '/_files', '/');
$this->directoryList->addDirectory(\Magento\Framework\App\Filesystem::MODULES_DIR, array('path' => $dirPath));
}
示例3: checkDependencies
/**
* Checks dependencies to package(s), returns array of dependencies in the format of
* 'package A' => [array of package names depending on package A]
* If $excludeSelf is set to true, items in $packages will be excluded in all
* "array of package names depending on package A"
*
* @param string[] $packages
* @param bool $excludeSelf
* @return string[]
*/
public function checkDependencies(array $packages, $excludeSelf = false)
{
$this->composerApp->setAutoExit(false);
$dependencies = [];
foreach ($packages as $package) {
$buffer = new BufferedOutput();
$this->composerApp->resetComposer();
$this->composerApp->run(new ArrayInput(['command' => 'depends', '--working-dir' => $this->directoryList->getRoot(), 'package' => $package]), $buffer);
$dependingPackages = $this->parseComposerOutput($buffer->fetch());
if ($excludeSelf === true) {
$dependingPackages = array_values(array_diff($dependingPackages, $packages));
}
$dependencies[$package] = $dependingPackages;
}
return $dependencies;
}
示例4: buildReport
/**
* Build Framework dependencies report
*
* @param string $outputPath
* @return void
*/
protected function buildReport($outputPath)
{
$root = $this->directoryList->getRoot();
$filePath = str_replace(
$root,
Files::init()->getPathToSource(),
$this->directoryList->getPath(DirectoryList::MODULES) . '/Magento'
);
$filesForParse = Files::init()->getFiles([$filePath], '*');
$configFiles = Files::init()->getConfigFiles('module.xml', [], false);
ServiceLocator::getFrameworkDependenciesReportBuilder()->build(
[
'parse' => [
'files_for_parse' => $filesForParse,
'config_files' => $configFiles,
'declared_namespaces' => Files::init()->getNamespaces(),
],
'write' => ['report_filename' => $outputPath],
]
);
}
示例5: getMediaBackupIgnorePaths
/**
* Get paths that should be excluded during iterative searches for locations for media backup only
*
* @return array
*/
private function getMediaBackupIgnorePaths()
{
$ignorePaths = [];
foreach (new \DirectoryIterator($this->directoryList->getRoot()) as $item) {
if (!$item->isDot() && ($this->directoryList->getPath(DirectoryList::PUB) !== $item->getPathname())) {
$ignorePaths[] = str_replace('\\', '/', $item->getPathname());
}
}
foreach (new \DirectoryIterator($this->directoryList->getPath(DirectoryList::PUB)) as $item) {
if (!$item->isDot() && ($this->directoryList->getPath(DirectoryList::MEDIA) !== $item->getPathname())) {
$ignorePaths[] = str_replace('\\', '/', $item->getPathname());
}
}
return $ignorePaths;
}
示例6: getFSDiskSpace
/**
* Get disk availability for filesystem backup
*
* @param string $type
* @return int
* @throws LocalizedException
*/
public function getFSDiskSpace($type = Factory::TYPE_FILESYSTEM)
{
$filesystemSize = 0;
if ($type === Factory::TYPE_FILESYSTEM) {
$ignorePaths = $this->getCodeBackupIgnorePaths();
} elseif ($type === Factory::TYPE_MEDIA) {
$ignorePaths = $this->getMediaBackupIgnorePaths();
} else {
throw new LocalizedException(new Phrase("This backup type '{$type}' is not supported."));
}
$filesInfo = $this->fsHelper->getInfo($this->directoryList->getRoot(), Helper::INFO_SIZE, $ignorePaths);
if ($filesInfo['size']) {
$filesystemSize = $filesInfo['size'];
}
return $filesystemSize;
}
示例7: compileCode
/**
* Compile Code
*
* @param string $generationDir
* @param array $fileExcludePatterns
* @param InputInterface $input
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
private function compileCode($generationDir, $fileExcludePatterns, $input)
{
$diDir = $input->getOption(self::INPUT_KEY_DI) ? $input->getOption(self::INPUT_KEY_DI) : $this->directoryList->getPath(DirectoryList::DI);
$relationsFile = $diDir . '/relations.ser';
$pluginDefFile = $diDir . '/plugins.ser';
$compilationDirs = [$this->directoryList->getPath(DirectoryList::SETUP) . '/Magento/Setup/Module', $this->directoryList->getRoot() . '/dev/tools/Magento/Tools'];
$compilationDirs = array_merge($compilationDirs, $this->componentRegistrar->getPaths(ComponentRegistrar::MODULE), $this->componentRegistrar->getPaths(ComponentRegistrar::LIBRARY));
$serializer = $input->getOption(self::INPUT_KEY_SERIALIZER) == Igbinary::NAME ? new Igbinary() : new Standard();
// 2.1 Code scan
$validator = new \Magento\Framework\Code\Validator();
$validator->add(new \Magento\Framework\Code\Validator\ConstructorIntegrity());
$validator->add(new \Magento\Framework\Code\Validator\ContextAggregation());
$classesScanner = new \Magento\Setup\Module\Di\Code\Reader\ClassesScanner();
$classesScanner->addExcludePatterns($fileExcludePatterns);
$directoryInstancesNamesList = new \Magento\Setup\Module\Di\Code\Reader\Decorator\Directory($this->log, new \Magento\Framework\Code\Reader\ClassReader(), $classesScanner, $validator, $generationDir);
foreach ($compilationDirs as $path) {
if (is_readable($path)) {
$directoryInstancesNamesList->getList($path);
}
}
$inheritanceScanner = new Scanner\InheritanceInterceptorScanner();
$this->entities['interceptors'] = $inheritanceScanner->collectEntities(get_declared_classes(), $this->entities['interceptors']);
// 2.1.1 Generation of Proxy and Interceptor Classes
foreach (['interceptors', 'di'] as $type) {
foreach ($this->entities[$type] as $entityName) {
switch ($this->generator->generateClass($entityName)) {
case \Magento\Framework\Code\Generator::GENERATION_SUCCESS:
$this->log->add(Log::GENERATION_SUCCESS, $entityName);
break;
case \Magento\Framework\Code\Generator::GENERATION_ERROR:
$this->log->add(Log::GENERATION_ERROR, $entityName);
break;
case \Magento\Framework\Code\Generator::GENERATION_SKIP:
default:
//no log
break;
}
}
}
//2.1.2 Compile relations for Proxy/Interceptor classes
$directoryInstancesNamesList->getList($generationDir);
$relations = $directoryInstancesNamesList->getRelations();
// 2.2 Compression
$relationsFileDir = dirname($relationsFile);
if (!file_exists($relationsFileDir)) {
mkdir($relationsFileDir, DriverInterface::WRITEABLE_DIRECTORY_MODE, true);
}
$relations = array_filter($relations);
file_put_contents($relationsFile, $serializer->serialize($relations));
// 3. Plugin Definition Compilation
$pluginScanner = new Scanner\CompositeScanner();
$pluginScanner->addChild(new Scanner\PluginScanner(), 'di');
$pluginDefinitions = [];
$pluginList = $pluginScanner->collectEntities($this->files);
$pluginDefinitionList = new \Magento\Framework\Interception\Definition\Runtime();
foreach ($pluginList as $type => $entityList) {
foreach ($entityList as $entity) {
$pluginDefinitions[ltrim($entity, '\\')] = $pluginDefinitionList->getMethodList($entity);
}
}
$outputContent = $serializer->serialize($pluginDefinitions);
$pluginDefFileDir = dirname($pluginDefFile);
if (!file_exists($pluginDefFileDir)) {
mkdir($pluginDefFileDir, DriverInterface::WRITEABLE_DIRECTORY_MODE, true);
}
file_put_contents($pluginDefFile, $outputContent);
}
示例8: readFile
protected function readFile($fileName)
{
$path = $this->directory_list->getRoot();
$directoryRead = $this->readFactory->create($path);
return $directoryRead->readFile($fileName);
}
示例9: testRoot
public function testRoot()
{
$object = new DirectoryList('/root/dir');
$this->assertEquals($object->getRoot(), $object->getPath(DirectoryList::ROOT));
}
示例10: __construct
/**
* @param DirectoryList $directoryList
*/
public function __construct(DirectoryList $directoryList)
{
$jsonFile = new JsonFile($directoryList->getRoot() . '/composer.json');
$this->composerJson = $jsonFile->read();
}
示例11: __construct
/**
* @param ServiceLocatorInterface $serviceLocator
* @param DirectoryList $directoryList
*/
public function __construct(ServiceLocatorInterface $serviceLocator, DirectoryList $directoryList)
{
$jsonFile = new JsonFile($directoryList->getRoot() . '/composer.json');
$this->composerJson = $jsonFile->read();
}