本文整理汇总了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));
}
示例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, []);
}
}
示例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());
}
}
示例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()));
}
示例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();
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}