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


PHP Filesystem::getDirectoryWrite方法代码示例

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


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

示例1: testGetDirectoryWrite

 public function testGetDirectoryWrite()
 {
     /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $dirWriteMock */
     $dirWriteMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\WriteInterface');
     $this->_dirWriteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($dirWriteMock));
     $this->assertEquals($dirWriteMock, $this->_filesystem->getDirectoryWrite(DirectoryList::ROOT));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:FilesystemTest.php

示例2: testExport

 /**
  * @magentoAppArea adminhtml
  * @magentoDbIsolation enabled
  * @magentoAppIsolation enabled
  * @magentoDataFixture Magento/Catalog/_files/product_simple.php
  */
 public function testExport()
 {
     $productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
     $index = 0;
     $ids = [];
     $origPricingData = [];
     while (isset($skus[$index])) {
         $ids[$index] = $productRepository->get($skus[$index])->getId();
         $origPricingData[$index] = $this->objectManager->create(\Magento\Catalog\Model\Product::class)->load($ids[$index])->getTierPrices();
         $index++;
     }
     $csvfile = uniqid('importexport_') . '.csv';
     $this->model->setWriter(\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\ImportExport\Model\Export\Adapter\Csv::class, ['fileSystem' => $this->fileSystem, 'destination' => $csvfile]));
     $this->assertNotEmpty($this->model->export());
     /** @var \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing $importModel */
     $importModel = $this->objectManager->create(\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::class);
     $directory = $this->fileSystem->getDirectoryWrite(DirectoryList::VAR_DIR);
     $source = $this->objectManager->create(\Magento\ImportExport\Model\Import\Source\Csv::class, ['file' => $csvfile, 'directory' => $directory]);
     $errors = $importModel->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'advanced_pricing'])->setSource($source)->validateData();
     $this->assertTrue($errors->getErrorsCount() == 0, 'Advanced Pricing import error, imported from file:' . $csvfile);
     $importModel->importData();
     while ($index > 0) {
         $index--;
         $newPricingData = $this->objectManager->create(\Magento\Catalog\Model\Product::class)->load($ids[$index])->getTierPrices();
         $this->assertEquals(count($origPricingData[$index]), count($newPricingData));
         $this->assertEqualsOtherThanSkippedAttributes($origPricingData[$index], $newPricingData, []);
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:34,代码来源:AdvancedPricingTest.php

示例3: ensureSourceFile

 /**
  * Make sure the aggregated configuration is materialized
  *
  * By default write the file if it doesn't exist, but in developer mode always do it.
  *
  * @param string $relPath
  * @return void
  */
 private function ensureSourceFile($relPath)
 {
     $dir = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW);
     if ($this->appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER || !$dir->isExist($relPath)) {
         $dir->writeFile($relPath, $this->config->getConfig());
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:FileManager.php

示例4: __construct

 /**
  * @param \Magento\Framework\App\Helper\Context $context
  * @param \Magento\Framework\Filesystem $filesystem
  * @param \Magento\Backend\Model\Session $session
  * @param \Magento\Framework\View\Design\Theme\FlyweightFactory $themeFactory
  */
 public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Framework\Filesystem $filesystem, \Magento\Backend\Model\Session $session, \Magento\Framework\View\Design\Theme\FlyweightFactory $themeFactory)
 {
     parent::__construct($context);
     $this->filesystem = $filesystem;
     $this->_session = $session;
     $this->_themeFactory = $themeFactory;
     $this->mediaDirectoryWrite = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
     $this->mediaDirectoryWrite->create($this->mediaDirectoryWrite->getRelativePath($this->getStorageRoot()));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:Storage.php

示例5: __construct

 /**
  * @param \Magento\Framework\Json\Encoder $encoder
  * @param \Magento\Framework\App\State $appState
  * @param \Psr\Log\LoggerInterface $logger
  * @param \Magento\Framework\Filesystem $filesystem
  */
 public function __construct(\Magento\Framework\Json\Encoder $encoder, \Magento\Framework\App\State $appState, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Filesystem $filesystem)
 {
     $this->encoder = $encoder;
     $this->_appState = $appState;
     $this->_logger = $logger;
     $this->_filesystem = $filesystem;
     $this->directoryWrite = $this->_filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
     $this->registerShutdownFunction();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:ErrorProcessor.php

示例6: publishAsset

 /**
  * Publish the asset
  *
  * @param Asset\LocalInterface $asset
  * @return bool
  */
 private function publishAsset(Asset\LocalInterface $asset)
 {
     $targetDir = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW);
     $rootDir = $this->filesystem->getDirectoryWrite(DirectoryList::ROOT);
     $source = $rootDir->getRelativePath($asset->getSourceFile());
     $destination = $asset->getPath();
     $strategy = $this->materializationStrategyFactory->create($asset);
     return $strategy->publishFile($rootDir, $targetDir, $source, $destination);
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:15,代码来源:Publisher.php

示例7: __construct

 /**
  * constructor
  *
  * @param Filesystem $filesystem
  * @param Encoder $encoder
  */
 public function __construct(Filesystem $filesystem, Encoder $encoder)
 {
     $this->filesystem = $filesystem;
     $this->encoder = $encoder;
     $this->connectDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
     $this->connectDirectory->create(Settings::VAR_DIR_NAME);
     $this->addTargetDir($this->connectDirectory->getAbsolutePath(Settings::VAR_DIR_NAME));
     $this->setCollectRecursively(false);
 }
开发者ID:nhc,项目名称:Umc_Base,代码行数:15,代码来源:Collection.php

示例8: lockProcess

 /**
  * @inheritdoc
  * @throws FileSystemException
  */
 public function lockProcess($lockName)
 {
     $this->tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
     $this->lockFilePath = $this->getFilePath($lockName);
     while ($this->isProcessLocked()) {
         sleep(1);
     }
     $this->tmpDirectory->writeFile($this->lockFilePath, time());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:LockerProcess.php

示例9: __construct

 /**
  * @param Database $coreFileStorageDb
  * @param Storage $coreFileStorage
  * @param NotProtectedExtension $validator
  * @param Filesystem $filesystem
  * @param LinkConfig $linkConfig
  * @param SampleConfig $sampleConfig
  */
 public function __construct(Database $coreFileStorageDb, Storage $coreFileStorage, NotProtectedExtension $validator, Filesystem $filesystem, LinkConfig $linkConfig, SampleConfig $sampleConfig)
 {
     $this->_validator = $validator;
     $this->_coreFileStorage = $coreFileStorage;
     $this->_coreFileStorageDb = $coreFileStorageDb;
     $this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
     $this->systemTmpDirectory = $filesystem->getDirectoryWrite(DirectoryList::SYS_TMP);
     $this->linkConfig = $linkConfig;
     $this->sampleConfig = $sampleConfig;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:ContentUploader.php

示例10: publishAsset

 /**
  * Publish the asset
  *
  * @param Asset\LocalInterface $asset
  * @return bool
  */
 private function publishAsset(Asset\LocalInterface $asset)
 {
     $targetDir = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW);
     $fullSource = $asset->getSourceFile();
     $source = basename($fullSource);
     $sourceDir = $this->writeFactory->create(dirname($fullSource));
     $destination = $asset->getPath();
     $strategy = $this->materializationStrategyFactory->create($asset);
     return $strategy->publishFile($sourceDir, $targetDir, $source, $destination);
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:16,代码来源:Publisher.php

示例11: launch

 /**
  * Run application
  *
  * @return int
  */
 public function launch()
 {
     /* Clean reports */
     $directory = $this->filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $path = $directory->getRelativePath($this->reportDir);
     if ($directory->isExist($path)) {
         $directory->delete($path);
     }
     /* Regenerate all indexers */
     $this->processor->reindexAll();
     return 0;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:Indexer.php

示例12: lockProcess

 /**
  * @inheritdoc
  * @throws FileSystemException
  */
 public function lockProcess($lockName)
 {
     if ($this->getState()->getMode() == State::MODE_PRODUCTION) {
         return;
     }
     $this->tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
     $this->lockFilePath = $this->getFilePath($lockName);
     while ($this->isProcessLocked()) {
         usleep(1000);
     }
     $this->tmpDirectory->writeFile($this->lockFilePath, time());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:LockerProcess.php

示例13: launch

 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     /* Clean reports */
     $directory = $this->filesystem->getDirectoryWrite(DirectoryList::ROOT);
     $path = $directory->getRelativePath($this->reportDir);
     if ($directory->isExist($path)) {
         $directory->delete($path);
     }
     /* Regenerate all indexers */
     $this->processor->reindexAll();
     $this->_response->setCode(0);
     return $this->_response;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:Indexer.php

示例14: __construct

 /**
  * @param Filesystem $filesystem
  * @param Filter $filter
  * @param MetadataProvider $metadataProvider
  * @param int $pageSize
  */
 public function __construct(Filesystem $filesystem, Filter $filter, MetadataProvider $metadataProvider, $pageSize = 200)
 {
     $this->filter = $filter;
     $this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
     $this->metadataProvider = $metadataProvider;
     $this->pageSize = $pageSize;
 }
开发者ID:uibar,项目名称:lavinia2,代码行数:13,代码来源:ConvertToCsv.php

示例15: __construct

 /**
  * Constructor
  *
  * @param MagentoComposerApplicationFactory $applicationFactory
  * @param \Magento\Framework\Filesystem $filesystem
  * @param ComposerInformation $composerInformation
  * @param ObjectManagerProvider $objectManagerProvider
  * @throws \Exception
  */
 public function __construct(MagentoComposerApplicationFactory $applicationFactory, Filesystem $filesystem, ComposerInformation $composerInformation, ObjectManagerProvider $objectManagerProvider)
 {
     $this->application = $applicationFactory->create();
     $this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
     $this->objectManager = $objectManagerProvider->get();
     $this->composerInformation = $composerInformation;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:UpdatePackagesCache.php


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