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


PHP Filesystem\DirectoryList类代码示例

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


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

示例1: load

 /**
  * Loads the configuration file
  *
  * @param string $fileKey
  * @return array
  * @throws \Exception
  */
 public function load($fileKey = null)
 {
     $path = $this->dirList->getPath(DirectoryList::CONFIG);
     if ($fileKey) {
         $result = @(include $path . '/' . $this->configFilePool->getPath($fileKey));
     } else {
         $configFiles = $this->configFilePool->getPaths();
         $result = [];
         foreach (array_keys($configFiles) as $fileKey) {
             $configFile = $path . '/' . $this->configFilePool->getPath($fileKey);
             $fileData = @(include $configFile);
             if (!empty($fileData)) {
                 $intersection = array_intersect_key($result, $fileData);
                 if (!empty($intersection)) {
                     $displayList = '';
                     foreach (array_keys($intersection) as $key) {
                         $displayList .= $key . PHP_EOL;
                     }
                     throw new \Exception("Key collision! The following keys occur in multiple config files:" . PHP_EOL . $displayList);
                 }
                 $result = array_merge($result, $fileData);
             }
         }
     }
     return $result ?: [];
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:33,代码来源:Reader.php

示例2: __construct

 public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Module\ModuleList $moduleList, \Magento\Framework\App\Config\MutableScopeConfigInterface $scopeConfig, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\Session\SessionManagerInterface $session, \Wyomind\Core\Helper\Data $coreHelper, \Magento\Framework\Filesystem\Directory\ReadFactory $directoryRead, \Magento\Framework\Filesystem\File\ReadFactory $fileRead, \Magento\Framework\App\Filesystem\DirectoryList $directoryList, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [])
 {
     parent::__construct($context, $registry, $resource, $resourceCollection, $data);
     $this->_magentoVersion = $coreHelper->getMagentoVersion();
     $this->_moduleList = $moduleList;
     $this->_scopeConfig = $scopeConfig;
     $this->_urlBuilder = $urlBuilder;
     $this->_cacheManager = $context->getCacheManager();
     $this->_session = $session;
     $this->_coreHelper = $coreHelper;
     $root = $directoryList->getPath(\Magento\Framework\App\Filesystem\DirectoryList::ROOT);
     if (file_exists($root . "/vendor/wyomind/")) {
         $this->_directoryRead = $directoryRead->create($root . "/vendor/wyomind/");
     } else {
         $this->_directoryRead = $directoryRead->create($root . "/app/code/Wyomind/");
     }
     $this->_httpRead = $fileRead;
     $this->_directoryList = $directoryList;
     $this->_version = $this->_moduleList->getOne("Wyomind_Core")['setup_version'];
     $this->_refreshCache = false;
     $this->getValues();
     foreach ($this->_values as $ext) {
         $this->checkActivation($ext);
     }
     if ($this->_refreshCache) {
         $this->_cacheManager->clean(['config']);
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:28,代码来源:Notifications.php

示例3: create

 /**
  * Create \Composer\Composer
  *
  * @return \Composer\Composer
  * @throws \Exception
  */
 public function create()
 {
     if (!getenv('COMPOSER_HOME')) {
         putenv('COMPOSER_HOME=' . $this->directoryList->getPath(DirectoryList::COMPOSER_HOME));
     }
     return \Composer\Factory::create(new BufferIO(), $this->composerJsonFinder->findComposerJson());
 }
开发者ID:mage2pro,项目名称:core,代码行数:13,代码来源:ComposerFactory.php

示例4: check

 /**
  * Check var/generation read and write access
  *
  * @return bool
  */
 public function check()
 {
     $initParams = $this->serviceManager->get(InitParamListener::BOOTSTRAP_PARAM);
     $filesystemDirPaths = isset($initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS]) ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] : [];
     $directoryList = new DirectoryList(BP, $filesystemDirPaths);
     $generationDirectoryPath = $directoryList->getPath(DirectoryList::GENERATION);
     $driverPool = new DriverPool();
     $fileWriteFactory = new WriteFactory($driverPool);
     /** @var \Magento\Framework\Filesystem\DriverInterface $driver */
     $driver = $driverPool->getDriver(DriverPool::FILE);
     $directoryWrite = new Write($fileWriteFactory, $driver, $generationDirectoryPath);
     if ($directoryWrite->isExist()) {
         if ($directoryWrite->isDirectory() || $directoryWrite->isReadable()) {
             try {
                 $probeFilePath = $generationDirectoryPath . DIRECTORY_SEPARATOR . uniqid(mt_rand()) . 'tmp';
                 $fileWriteFactory->create($probeFilePath, DriverPool::FILE, 'w');
                 $driver->deleteFile($probeFilePath);
             } catch (\Exception $e) {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         try {
             $directoryWrite->create();
         } catch (\Exception $e) {
             return false;
         }
     }
     return true;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:37,代码来源:GenerationDirectoryAccess.php

示例5: 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 . '/..']));
 }
开发者ID:nja78,项目名称:magento2,代码行数:13,代码来源:Remove.php

示例6: load

 /**
  * Loads the configuration file
  *
  * @param string $fileKey
  * @return array
  * @throws \Exception
  */
 public function load($fileKey = null)
 {
     $path = $this->dirList->getPath(DirectoryList::CONFIG);
     $fileDriver = $this->driverPool->getDriver(DriverPool::FILE);
     $result = [];
     if ($fileKey) {
         $filePath = $path . '/' . $this->configFilePool->getPath($fileKey);
         if ($fileDriver->isExists($filePath)) {
             $result = (include $filePath);
         }
     } else {
         $configFiles = $this->configFilePool->getPaths();
         $allFilesData = [];
         $result = [];
         foreach (array_keys($configFiles) as $fileKey) {
             $configFile = $path . '/' . $this->configFilePool->getPath($fileKey);
             if ($fileDriver->isExists($configFile)) {
                 $fileData = (include $configFile);
             } else {
                 continue;
             }
             $allFilesData[$configFile] = $fileData;
             if (!empty($fileData)) {
                 $intersection = array_intersect_key($result, $fileData);
                 if (!empty($intersection)) {
                     $displayMessage = $this->findFilesWithKeys(array_keys($intersection), $allFilesData);
                     throw new \Exception("Key collision! The following keys occur in multiple config files:" . PHP_EOL . $displayMessage);
                 }
                 $result = array_merge($result, $fileData);
             }
         }
     }
     return $result ?: [];
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:41,代码来源:Reader.php

示例7: updateTranslationFileContent

 /**
  * @param string $content
  * @return void
  */
 public function updateTranslationFileContent($content)
 {
     $translationDir = $this->directoryList->getPath(DirectoryList::STATIC_VIEW) . \DIRECTORY_SEPARATOR . $this->assetRepo->getStaticViewFileContext()->getPath();
     if (!$this->driverFile->isExists($this->getTranslationFileFullPath())) {
         $this->driverFile->createDirectory($translationDir);
     }
     $this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:FileManager.php

示例8: updateTranslationFileContent

 /**
  * @param string $content
  * @return void
  */
 public function updateTranslationFileContent($content)
 {
     $translationDir = $this->directoryList->getPath(DirectoryList::STATIC_VIEW) . \DIRECTORY_SEPARATOR . $this->assetRepo->getStaticViewFileContext()->getPath();
     if (!$this->driverFile->isExists($this->getTranslationFileFullPath())) {
         $this->driverFile->createDirectory($translationDir, \Magento\Framework\Filesystem\Driver\File::WRITEABLE_DIRECTORY_MODE);
     }
     $this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:12,代码来源:FileManager.php

示例9: findComposerJson

 /**
  * Find absolute path to root Composer json file
  *
  * @return string
  * @throws \Exception
  */
 public function findComposerJson()
 {
     $composerJson = $this->directoryList->getPath(DirectoryList::ROOT) . '/composer.json';
     $composerJson = realpath($composerJson);
     if ($composerJson === false) {
         throw new \Exception('Composer file not found');
     }
     return $composerJson;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:ComposerJsonFinder.php

示例10: load

 /**
  * Loads the configuration file
  *
  * @param string $configFile
  * @return array
  */
 public function load($configFile = null)
 {
     if ($configFile) {
         $file = $this->dirList->getPath(DirectoryList::CONFIG) . '/' . $configFile;
     } else {
         $file = $this->dirList->getPath(DirectoryList::CONFIG) . '/' . $this->file;
     }
     $result = @(include $file);
     return $result ?: [];
 }
开发者ID:opexsw,项目名称:magento2,代码行数:16,代码来源:Reader.php

示例11: getApplicationNonWritableDirectories

 /**
  * Retrieve list of recommended non-writable directories for application
  *
  * @return array
  */
 public function getApplicationNonWritableDirectories()
 {
     if (!$this->applicationNonWritableDirectories) {
         $data = [DirectoryList::CONFIG];
         foreach ($data as $code) {
             $this->applicationNonWritableDirectories[$code] = $this->directoryList->getPath($code);
         }
     }
     return array_values($this->applicationNonWritableDirectories);
 }
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:15,代码来源:FilePermissions.php

示例12: testDirectoriesCustomization

 public function testDirectoriesCustomization()
 {
     $config = [DirectoryList::APP => [DirectoryList::PATH => 'foo', DirectoryList::URL_PATH => 'bar']];
     $object = new DirectoryList('/root/dir', $config);
     $this->assertFileExists($object->getPath(DirectoryList::SYS_TMP));
     $this->assertEquals('/root/dir/foo', $object->getPath(DirectoryList::APP));
     $this->assertEquals('bar', $object->getUrlPath(DirectoryList::APP));
     $this->setExpectedException('\\Magento\\Framework\\Filesystem\\FilesystemException', "Unknown directory type: 'unknown'");
     $object->getPath('unknown');
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:DirectoryListTest.php

示例13: findComposerJson

 /**
  * Find absolute path to root Composer json file
  *
  * @return string
  * @throws \Exception
  */
 public function findComposerJson()
 {
     // composer.json is in same directory as vendor
     $vendorPath = $this->directoryList->getPath(DirectoryList::CONFIG) . '/vendor_path.php';
     $vendorDir = (require "{$vendorPath}");
     $composerJson = $this->directoryList->getPath(DirectoryList::ROOT) . "/{$vendorDir}/../composer.json";
     $composerJson = realpath($composerJson);
     if ($composerJson === false) {
         throw new \Exception('Composer file not found');
     }
     return $composerJson;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:ComposerJsonFinder.php

示例14: __construct

 /**
  * File constructor.
  *
  * @param Data                                            $helper
  * @param \Magento\Framework\App\Filesystem\DirectoryList $directoryList
  * @param \Magento\Framework\Filesystem                   $filesystem
  */
 public function __construct(\Dotdigitalgroup\Email\Helper\Data $helper, \Magento\Framework\App\Filesystem\DirectoryList $directoryList, \Magento\Framework\Filesystem $filesystem)
 {
     $this->helper = $helper;
     $this->directoryList = $directoryList;
     $this->filesystem = $filesystem;
     $var = $directoryList->getPath('var');
     $this->outputFolder = $var . DIRECTORY_SEPARATOR . 'export' . DIRECTORY_SEPARATOR . 'email';
     $this->outputArchiveFolder = $this->outputFolder . DIRECTORY_SEPARATOR . 'archive';
     $this->delimiter = ',';
     // tab character
     $this->enclosure = '"';
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:19,代码来源:File.php

示例15: setUp

 public function setUp()
 {
     $this->composerJsonFinder = $this->getMock('Magento\\Framework\\Composer\\ComposerJsonFinder', [], [], '', false);
     $this->composerJsonFinder->expects($this->once())->method('findComposerJson')->willReturn('composer.json');
     $this->directoryList = $this->getMock('Magento\\Framework\\App\\Filesystem\\DirectoryList', [], [], '', false);
     $this->directoryList->expects($this->exactly(2))->method('getPath')->willReturn('var');
     $this->reqUpdDryRunCommand = $this->getMock('Magento\\Composer\\RequireUpdateDryRunCommand', [], [], '', false);
     $this->file = $this->getMock('Magento\\Framework\\Filesystem\\Driver\\File', [], [], '', false);
     $this->file->expects($this->once())->method('copy')->with('composer.json', 'var/composer.json');
     $composerAppFactory = $this->getMock('Magento\\Framework\\Composer\\MagentoComposerApplicationFactory', [], [], '', false);
     $composerAppFactory->expects($this->once())->method('createRequireUpdateDryRunCommand')->willReturn($this->reqUpdDryRunCommand);
     $this->dependencyReadinessCheck = new DependencyReadinessCheck($this->composerJsonFinder, $this->directoryList, $this->file, $composerAppFactory);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:DependencyReadinessCheckTest.php


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