• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Filesystem\DirectoryList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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));
 }
开发者ID:,项目名称:,代码行数:14,代码来源:


示例17: populateMappings

 /**
  * @param AutoloaderInterface $autoloader
  * @param DirectoryList $dirList
  * @return void
  */
 public static function populateMappings(AutoloaderInterface $autoloader, DirectoryList $dirList)
 {
     $generationDir = $dirList->getPath(DirectoryList::GENERATION);
     $frameworkDir = $dirList->getPath(DirectoryList::LIB_INTERNAL);
     $autoloader->addPsr4('Magento\\', [$generationDir . '/Magento/'], true);
     $autoloader->addPsr0('Cm_', $frameworkDir, true);
     $autoloader->addPsr0('Credis_', $frameworkDir, true);
     /** Required for Zend functionality */
     FileResolver::addIncludePath($frameworkDir);
     /** Required for code generation to occur */
     FileResolver::addIncludePath($generationDir);
     /** Required to autoload custom classes */
     $autoloader->addPsr0('', [$generationDir]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:Populator.php


示例18: add

 public function add($contentFile, $cssFile)
 {
     $styleContent = preg_replace('/^\\/\\*[\\s\\S]+\\*\\//', '', file_get_contents($contentFile));
     if (empty($styleContent)) {
         return;
     }
     $mediaDir = $this->directoryList->getPath(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
     file_put_contents("{$mediaDir}/{$cssFile}", $styleContent, FILE_APPEND);
     $linkText = sprintf('<link  rel="stylesheet" type="text/css"  media="all" href="{{MEDIA_URL}}%s" />', $cssFile);
     $miscScriptsNode = 'design/head/includes';
     $miscScripts = $this->scopeConfig->getValue($miscScriptsNode);
     if (!$miscScripts || strpos($miscScripts, $linkText) === false) {
         $this->configWriter->save($miscScriptsNode, $miscScripts . $linkText);
         $this->configCacheType->clean();
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:HeadStyle.php


示例19: checkRecursiveDirectories

    /**
     * Check all sub-directories and files except for var/generation and var/di
     *
     * @param string $directory
     * @return bool
     */
    private function checkRecursiveDirectories($directory)
    {
        $directoryIterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::CHILD_FIRST
        );
        $noWritableFilesFolders = [
            $this->directoryList->getPath(DirectoryList::GENERATION) . '/',
            $this->directoryList->getPath(DirectoryList::DI) . '/',
        ];

        $directoryIterator = new Filter($directoryIterator, $noWritableFilesFolders);

        $directoryIterator = new ExcludeFilter(
            $directoryIterator,
            [
                $this->directoryList->getPath(DirectoryList::SESSION) . '/',
            ]
        );

        $foundNonWritable = false;

        try {
            foreach ($directoryIterator as $subDirectory) {
                if (!$subDirectory->isWritable() && !$subDirectory->isLink()) {
                    $this->nonWritablePathsInDirectories[$directory][] = $subDirectory;
                    $foundNonWritable = true;
                }
            }
        } catch (\UnexpectedValueException $e) {
            return false;
        }
        return !$foundNonWritable;
    }
开发者ID:rafaelstz,项目名称:magento2,代码行数:40,代码来源:FilePermissions.php


示例20: setUpDirectoryListInstallation

 public function setUpDirectoryListInstallation()
 {
     $this->directoryListMock->expects($this->at(0))->method('getPath')->with(DirectoryList::CONFIG)->will($this->returnValue(BP . '/app/etc'));
     $this->directoryListMock->expects($this->at(1))->method('getPath')->with(DirectoryList::VAR_DIR)->will($this->returnValue(BP . '/var'));
     $this->directoryListMock->expects($this->at(2))->method('getPath')->with(DirectoryList::MEDIA)->will($this->returnValue(BP . '/pub/media'));
     $this->directoryListMock->expects($this->at(3))->method('getPath')->with(DirectoryList::STATIC_VIEW)->will($this->returnValue(BP . '/pub/static'));
 }
开发者ID:Zash22,项目名称:magento,代码行数:7,代码来源:FilePermissionsTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Helper\AbstractHelper类代码示例发布时间:2022-05-23
下一篇:
PHP Config\Value类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap