本文整理汇总了PHP中Magento\Framework\App\Filesystem::getDirectoryWrite方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::getDirectoryWrite方法的具体用法?PHP Filesystem::getDirectoryWrite怎么用?PHP Filesystem::getDirectoryWrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Filesystem
的用法示例。
在下文中一共展示了Filesystem::getDirectoryWrite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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(\Magento\Framework\App\Filesystem::STATIC_VIEW_DIR);
if ($this->appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER || !$dir->isExist($relPath)) {
$dir->writeFile($relPath, $this->config->getConfig());
}
}
示例2: __construct
/**
* Set base dir
*
* @param \Magento\Core\Model\EntityFactory $entityFactory
* @param \Magento\Framework\App\Filesystem $filesystem
*/
public function __construct(\Magento\Core\Model\EntityFactory $entityFactory, \Magento\Framework\App\Filesystem $filesystem)
{
parent::__construct($entityFactory);
$this->filesystem = $filesystem;
$this->connectDirectory = $this->filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
$this->connectDirectory->create('connect');
$this->addTargetDir($this->connectDirectory->getAbsolutePath('connect'));
}
示例3: __construct
/**
* Constructor
*
* @param \Magento\Framework\Convert\ConvertArray $convertArray
* @param \Magento\Framework\App\Filesystem $filesystem
* @param Session $session
* @param \Magento\Framework\Logger $logger
* @param array $data
*/
public function __construct(\Magento\Framework\Convert\ConvertArray $convertArray, \Magento\Framework\App\Filesystem $filesystem, \Magento\Connect\Model\Session $session, \Magento\Framework\Logger $logger, array $data = array())
{
$this->_convertArray = $convertArray;
$this->_session = $session;
$this->filesystem = $filesystem;
$this->writeDirectory = $this->filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
$this->logger = $logger;
parent::__construct($data);
}
示例4: __construct
/**
* @param \Magento\Core\Helper\Data $helper
* @param \Magento\Framework\App\State $appState
* @param \Magento\Framework\Logger $logger
* @param \Magento\Framework\App\Filesystem $filesystem
*/
public function __construct(\Magento\Core\Helper\Data $helper, \Magento\Framework\App\State $appState, \Magento\Framework\Logger $logger, \Magento\Framework\App\Filesystem $filesystem)
{
$this->_coreHelper = $helper;
$this->_appState = $appState;
$this->_logger = $logger;
$this->_filesystem = $filesystem;
$this->directoryWrite = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
$this->registerShutdownFunction();
}
示例5: __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(Filesystem::MEDIA_DIR);
$this->systemTmpDirectory = $filesystem->getDirectoryWrite(Filesystem::SYS_TMP_DIR);
$this->linkConfig = $linkConfig;
$this->sampleConfig = $sampleConfig;
}
示例6: __construct
/**
* Initialize dependencies
*
* @param \Magento\Framework\App\Filesystem $filesystem
* @param \Magento\Theme\Helper\Storage $helper
* @param \Magento\Framework\ObjectManager $objectManager
* @param \Magento\Framework\Image\AdapterFactory $imageFactory
*/
public function __construct(\Magento\Framework\App\Filesystem $filesystem, \Magento\Theme\Helper\Storage $helper, \Magento\Framework\ObjectManager $objectManager, \Magento\Framework\Image\AdapterFactory $imageFactory)
{
$this->mediaWriteDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
$this->_helper = $helper;
$this->_objectManager = $objectManager;
$this->_imageFactory = $imageFactory;
}
示例7: __construct
/**
* @param \Magento\Framework\Logger $logger
* @param \Magento\Framework\App\Filesystem $filesystem
* @param \Magento\Framework\Logger\AdapterFactory $adapterFactory
* @param array $data
*/
public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\Logger\AdapterFactory $adapterFactory, array $data = array())
{
$this->_logger = $logger;
$this->_varDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
$this->_adapterFactory = $adapterFactory;
parent::__construct($data);
}
示例8: _checkFullPath
/**
* Check file system full path
*
* @param string $fullPath
* @param bool $recursive
* @param bool $existence
* @return bool
*/
protected function _checkFullPath($fullPath, $recursive, $existence)
{
$result = true;
$directory = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR);
$path = $directory->getRelativePath($fullPath);
if ($recursive && $directory->isDirectory($path)) {
$pathsToCheck = $directory->read($path);
array_unshift($pathsToCheck, $path);
} else {
$pathsToCheck = array($path);
}
$skipFileNames = array('.svn', '.htaccess');
foreach ($pathsToCheck as $pathToCheck) {
if (in_array(basename($pathToCheck), $skipFileNames)) {
continue;
}
if ($existence) {
$setError = !$directory->isWritable($path);
} else {
$setError = $directory->isExist($path) && !$directory->isWritable($path);
}
if ($setError) {
$this->messageManager->addError(__('Path "%1" must be writable.', $pathToCheck));
$result = false;
}
}
return $result;
}
示例9: create
/**
* {@inheritdoc}
*/
public function create($productSku, GalleryEntry $entry, GalleryEntryContent $entryContent, $storeId = 0)
{
$store = $this->storeFactory->create()->load($storeId);
if ($store->getId() != $storeId) {
throw new NoSuchEntityException('There is no store with provided ID.');
}
if (!$this->contentValidator->isValid($entryContent)) {
throw new InputException('The image content is not valid.');
}
$product = $this->productLoader->load($productSku);
$fileContent = @base64_decode($entryContent->getData(), true);
$mediaTmpPath = $this->mediaConfig->getBaseTmpMediaPath();
$mediaDirectory = $this->filesystem->getDirectoryWrite(Filesystem::MEDIA_DIR);
$mediaDirectory->create($mediaTmpPath);
$fileName = $entryContent->getName() . '.' . $this->mimeTypeExtensionMap[$entryContent->getMimeType()];
$relativeFilePath = $mediaTmpPath . DIRECTORY_SEPARATOR . $fileName;
$absoluteFilePath = $mediaDirectory->getAbsolutePath($relativeFilePath);
$mediaDirectory->writeFile($relativeFilePath, $fileContent);
/** @var $productMediaGallery \Magento\Catalog\Model\Product\Attribute\Backend\Media */
$productMediaGallery = $this->getGalleryAttributeBackend($product);
$imageFileUri = $productMediaGallery->addImage($product, $absoluteFilePath, $entry->getTypes(), true, $entry->isDisabled());
// Update additional fields that are still empty after addImage call
$productMediaGallery->updateImage($product, $imageFileUri, array('label' => $entry->getLabel(), 'position' => $entry->getPosition(), 'disabled' => $entry->isDisabled()));
$product->setStoreId($storeId);
$product->save();
// Remove all temporary files
$mediaDirectory->delete($relativeFilePath);
// File could change its name during the move from tmp dir
return $this->entryResolver->getEntryIdByFilePath($product, $productMediaGallery->getRenamedImage($imageFileUri));
}
示例10: _saveViewConfiguration
/**
* Save customized DOM of view configuration
*
* @param \DOMDocument $config
* @return $this
*/
protected function _saveViewConfiguration(\DOMDocument $config)
{
$targetPath = $this->_theme->getCustomization()->getCustomViewConfigPath();
$directory = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR);
$directory->writeFile($directory->getRelativePath($targetPath), $config->saveXML());
return $this;
}
示例11: __construct
/**
* @param \Magento\Framework\App\Filesystem $filesystem
* @param \Magento\Core\Helper\File\Storage\Database $fileStorageDatabase
* @param \Magento\Core\Model\File\Storage\DatabaseFactory $storageDatabaseFactory
* @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
*/
public function __construct(\Magento\Framework\App\Filesystem $filesystem, \Magento\Core\Helper\File\Storage\Database $fileStorageDatabase, \Magento\Core\Model\File\Storage\DatabaseFactory $storageDatabaseFactory, \Magento\Framework\App\Response\Http\FileFactory $fileFactory)
{
$this->_rootDir = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR);
$this->_fileStorageDatabase = $fileStorageDatabase;
$this->_storageDatabaseFactory = $storageDatabaseFactory;
$this->_fileFactory = $fileFactory;
}
示例12: __construct
/**
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Framework\Logger $logger
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
* @param \Magento\Core\Helper\Data $coreData
* @param \Magento\Core\Model\File\Validator\NotProtectedExtension $fileValidator
* @param \Magento\Framework\App\Filesystem $filesystem
*/
public function __construct(\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Logger $logger, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Core\Helper\Data $coreData, \Magento\Core\Model\File\Validator\NotProtectedExtension $fileValidator, \Magento\Framework\App\Filesystem $filesystem)
{
parent::__construct($localeDate, $logger, $localeResolver);
$this->_coreData = $coreData;
$this->_fileValidator = $fileValidator;
$this->_directory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
}
示例13: __construct
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Core\Model\File\UploaderFactory $uploaderFactory
* @param \Magento\Backend\Model\Config\Backend\File\RequestData\RequestDataInterface $requestData
* @param \Magento\Framework\App\Filesystem $filesystem
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\Db $resourceCollection
* @param array $data
*/
public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Core\Model\File\UploaderFactory $uploaderFactory, \Magento\Backend\Model\Config\Backend\File\RequestData\RequestDataInterface $requestData, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array())
{
$this->_uploaderFactory = $uploaderFactory;
$this->_requestData = $requestData;
$this->_filesystem = $filesystem;
$this->_mediaDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data);
}
示例14: __construct
/**
* @param Resource\LogFactory $resLogFactory
* @param \Magento\Captcha\Helper\Data $helper
* @param \Magento\Captcha\Helper\Adminhtml\Data $adminHelper
* @param \Magento\Framework\App\Filesystem $filesystem
* @param \Magento\Store\Model\StoreManager $storeManager
*/
public function __construct(Resource\LogFactory $resLogFactory, \Magento\Captcha\Helper\Data $helper, \Magento\Captcha\Helper\Adminhtml\Data $adminHelper, \Magento\Framework\App\Filesystem $filesystem, \Magento\Store\Model\StoreManager $storeManager)
{
$this->_resLogFactory = $resLogFactory;
$this->_helper = $helper;
$this->_adminHelper = $adminHelper;
$this->_mediaDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
$this->_storeManager = $storeManager;
}
示例15: getImgDir
/**
* Get captcha image directory
*
* @param mixed $website
* @return string
*/
public function getImgDir($website = null)
{
$mediaDir = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
$captchaDir = '/captcha/' . $this->_getWebsiteCode($website);
$mediaDir->create($captchaDir);
$mediaDir->changePermissions($captchaDir, 0775);
return $mediaDir->getAbsolutePath($captchaDir) . '/';
}