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


PHP Filesystem::getDirectoryRead方法代码示例

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


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

示例1: __construct

 /**
  * @param Filesystem $filesystem
  * @param \Magento\Framework\Config\FileIteratorFactory $iteratorFactory
  */
 public function __construct(Filesystem $filesystem, \Magento\Framework\Config\FileIteratorFactory $iteratorFactory)
 {
     $this->iteratorFactory = $iteratorFactory;
     $this->modulesDirectory = $filesystem->getDirectoryRead(Filesystem::MODULES_DIR);
     $this->configDirectory = $filesystem->getDirectoryRead(Filesystem::CONFIG_DIR);
     $this->rootDirectory = $filesystem->getDirectoryRead(Filesystem::ROOT_DIR);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:11,代码来源:FileResolver.php

示例2: __construct

 /**
  * @param \Magento\Framework\App\Helper\Context $context
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\Framework\App\State $appState
  * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Framework\Convert\Xml $xmlConverter
  * @param bool $dbCompatibleMode
  */
 public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\Convert\Xml $xmlConverter, $dbCompatibleMode = true)
 {
     $this->filesystem = $filesystem;
     $this->readDirectory = $this->filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::VAR_DIR);
     $this->_xmlConverter = $xmlConverter;
     parent::__construct($context, $scopeConfig, $storeManager, $appState, $priceCurrency, $dbCompatibleMode);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:17,代码来源:Data.php

示例3: afterSave

 /**
  * After save
  *
  * @param \Magento\Framework\Object $object
  * @return $this|void
  */
 public function afterSave($object)
 {
     $value = $object->getData($this->getAttribute()->getName());
     if (is_array($value) && !empty($value['delete'])) {
         $object->setData($this->getAttribute()->getName(), '');
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
         return;
     }
     try {
         /** @var $uploader \Magento\Core\Model\File\Uploader */
         $uploader = $this->_fileUploaderFactory->create(array('fileId' => $this->getAttribute()->getName()));
         $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
         $uploader->setAllowRenameFiles(true);
         $uploader->setFilesDispersion(true);
     } catch (\Exception $e) {
         return $this;
     }
     $path = $this->_filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::MEDIA_DIR)->getAbsolutePath('catalog/product/');
     $uploader->save($path);
     $fileName = $uploader->getUploadedFileName();
     if ($fileName) {
         $object->setData($this->getAttribute()->getName(), $fileName);
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:32,代码来源:Image.php

示例4: __construct

 /**
  * @param \Magento\Framework\Code\Minifier\StrategyInterface $strategy
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param string $directoryName
  */
 public function __construct(\Magento\Framework\Code\Minifier\StrategyInterface $strategy, \Magento\Framework\App\Filesystem $filesystem, $directoryName)
 {
     $this->_strategy = $strategy;
     $this->rootDirectory = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $this->pubViewCacheDir = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::PUB_VIEW_CACHE_DIR);
     $this->directoryName = $directoryName;
 }
开发者ID:Mohitsahu123,项目名称:mtf,代码行数:12,代码来源:Minifier.php

示例5: __construct

 /**
  * @param \Magento\Framework\App\Filesystem                   $filesystem
  * @param \Magento\Framework\Module\Dir\Reader            $moduleReader
  * @param \Magento\Framework\Config\FileIteratorFactory   $iteratorFactory
  */
 public function __construct(\Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\Module\Dir\Reader $moduleReader, \Magento\Framework\Config\FileIteratorFactory $iteratorFactory)
 {
     $this->themesDirectory = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::THEMES_DIR);
     $this->modulesDirectory = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::MODULES_DIR);
     $this->iteratorFactory = $iteratorFactory;
     $this->_moduleReader = $moduleReader;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:FileResolver.php

示例6: afterSave

 /**
  * Save uploaded file and set its name to category
  *
  * @param \Magento\Framework\Object $object
  * @return \Magento\Catalog\Model\Category\Attribute\Backend\Image
  */
 public function afterSave($object)
 {
     $value = $object->getData($this->getAttribute()->getName() . '_additional_data');
     // if no image was set - nothing to do
     if (empty($value) && empty($_FILES)) {
         return $this;
     }
     if (is_array($value) && !empty($value['delete'])) {
         $object->setData($this->getAttribute()->getName(), '');
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
         return $this;
     }
     $path = $this->_filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::MEDIA_DIR)->getAbsolutePath('catalog/category/');
     try {
         /** @var $uploader \Magento\Core\Model\File\Uploader */
         $uploader = $this->_fileUploaderFactory->create(array('fileId' => $this->getAttribute()->getName()));
         $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
         $uploader->setAllowRenameFiles(true);
         $result = $uploader->save($path);
         $object->setData($this->getAttribute()->getName(), $result['file']);
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
     } catch (\Exception $e) {
         if ($e->getCode() != \Magento\Core\Model\File\Uploader::TMP_NAME_EMPTY) {
             $this->_logger->logException($e);
         }
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:34,代码来源:Image.php

示例7: aroundCleanMergedJsCss

 /**
  * Clean files in database on cleaning merged assets
  *
  * @param \Magento\Framework\View\Asset\MergeService $subject
  * @param callable $proceed
  *
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundCleanMergedJsCss(\Magento\Framework\View\Asset\MergeService $subject, \Closure $proceed)
 {
     $proceed();
     /** @var \Magento\Framework\Filesystem\Directory\ReadInterface $pubStaticDirectory */
     $pubStaticDirectory = $this->filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::STATIC_VIEW_DIR);
     $mergedDir = $pubStaticDirectory->getAbsolutePath() . '/' . \Magento\Framework\View\Asset\Merged::getRelativeDir();
     $this->database->deleteFolder($mergedDir);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:CleanMergedJsCss.php

示例8: render

 /**
  * Prepare link to display in grid
  *
  * @param \Magento\Framework\Object $row
  * @return string
  */
 public function render(\Magento\Framework\Object $row)
 {
     /** @var $sitemap \Magento\Sitemap\Model\Sitemap */
     $sitemap = $this->_sitemapFactory->create();
     $url = $this->escapeHtml($sitemap->getSitemapUrl($row->getSitemapPath(), $row->getSitemapFilename()));
     $fileName = preg_replace('/^\\//', '', $row->getSitemapPath() . $row->getSitemapFilename());
     $directory = $this->_filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::ROOT_DIR);
     if ($directory->isFile($fileName)) {
         return sprintf('<a href="%1$s">%1$s</a>', $url);
     }
     return $url;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:Link.php

示例9: validateMaxSize

 /**
  * Validation callback for checking max file size
  *
  * @param  string $filePath Path to temporary uploaded file
  * @return void
  * @throws \Magento\Framework\Model\Exception
  */
 public function validateMaxSize($filePath)
 {
     $directory = $this->_filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::SYS_TMP_DIR);
     if ($this->_maxFileSize > 0 && $directory->stat($directory->getRelativePath($filePath))['size'] > $this->_maxFileSize * 1024) {
         throw new \Magento\Framework\Model\Exception(__('The file you\'re uploading exceeds the server size limit of %1 kilobytes.', $this->_maxFileSize));
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:File.php

示例10: __construct

 /**
  * @param \Magento\Framework\Model\Context $context
  * @param \Magento\Framework\Registry $registry
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
  * @param \Magento\Paypal\Model\CertFactory $certFactory
  * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
  * @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\Paypal\Model\CertFactory $certFactory, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array())
 {
     $this->_certFactory = $certFactory;
     $this->_encryptor = $encryptor;
     $this->_tmpDirectory = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::SYS_TMP_DIR);
     parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:Cert.php

示例11: __construct

 /**
  * @param \Magento\Framework\App\RequestInterface $request
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Framework\StoreManagerInterface $storeManager
  * @param \Magento\Framework\Message\ManagerInterface $messageManager
  */
 public function __construct(\Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Message\ManagerInterface $messageManager)
 {
     $this->_request = $request;
     $this->_storeManager = $storeManager;
     $this->_filesystem = $filesystem;
     $this->_pubDirectory = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::PUB_DIR);
     $this->_configDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::CONFIG_DIR);
     $this->messageManager = $messageManager;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:15,代码来源:Config.php

示例12: collectFileInfo

 /**
  * Collect file info
  *
  * Return array(
  *  filename    => string
  *  content     => string|bool
  *  update_time => string
  *  directory   => string
  *
  * @param string $mediaDirectory
  * @param string $path
  * @return array
  * @throws \Magento\Framework\Model\Exception
  */
 public function collectFileInfo($mediaDirectory, $path)
 {
     $path = ltrim($path, '\\/');
     $fullPath = $mediaDirectory . '/' . $path;
     $dir = $this->filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::MEDIA_DIR);
     $relativePath = $dir->getRelativePath($fullPath);
     if (!$dir->isFile($relativePath)) {
         throw new \Magento\Framework\Model\Exception(__('File %1 does not exist', $fullPath));
     }
     if (!$dir->isReadable($relativePath)) {
         throw new \Magento\Framework\Model\Exception(__('File %1 is not readable', $fullPath));
     }
     $path = str_replace(array('/', '\\'), '/', $path);
     $directory = dirname($path);
     if ($directory == '.') {
         $directory = null;
     }
     return array('filename' => basename($path), 'content' => $dir->readFile($relativePath), 'update_time' => $this->_date->date(), 'directory' => $directory);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:33,代码来源:Media.php

示例13: __construct

 /**
  * Initialize dependencies.
  *
  * @param \Magento\Framework\ObjectManager $objectManager
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Webapi\Model\Config $config
  * @param \Magento\Webapi\Model\Config\ClassReflector $classReflector
  * @param \Magento\Webapi\Helper\Data $helper
  */
 public function __construct(\Magento\Framework\ObjectManager $objectManager, \Magento\Framework\App\Filesystem $filesystem, \Magento\Webapi\Model\Config $config, \Magento\Webapi\Model\Config\ClassReflector $classReflector, \Magento\Webapi\Helper\Data $helper)
 {
     // TODO: Check if Service specific XSD is already cached
     $this->modulesDirectory = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::MODULES_DIR);
     $this->_config = $config;
     $this->_objectManager = $objectManager;
     $this->_helper = $helper;
     $this->_classReflector = $classReflector;
     $this->_initServicesMetadata();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:19,代码来源:Config.php

示例14: __construct

 /**
  * @param \Magento\Install\Model\Installer\ConsoleFactory $installerFactory
  * @param \Magento\Install\App\Output $output
  * @param \Magento\Framework\App\State $state
  * @param \Magento\Framework\App\ObjectManager\ConfigLoader $loader
  * @param \Magento\Framework\ObjectManager $objectManager
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param Response $response
  * @param array $arguments
  */
 public function __construct(\Magento\Install\Model\Installer\ConsoleFactory $installerFactory, \Magento\Install\App\Output $output, \Magento\Framework\App\State $state, \Magento\Framework\App\ObjectManager\ConfigLoader $loader, \Magento\Framework\ObjectManager $objectManager, \Magento\Framework\App\Filesystem $filesystem, Response $response, array $arguments = array())
 {
     $this->rootDirectory = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $this->_loader = $loader;
     $this->_state = $state;
     $this->_installerFactory = $installerFactory;
     $this->_arguments = $this->_buildInitArguments($arguments);
     $this->_output = $output;
     $this->_response = $response;
     $this->_objectManager = $objectManager;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:21,代码来源:Console.php

示例15: getStorageData

 /**
  * Collect files and directories recursively
  *
  * @param string $dir
  * @return array
  */
 public function getStorageData($dir = '/')
 {
     $files = array();
     $directories = array();
     $directoryInstance = $this->_filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::MEDIA_DIR);
     if ($directoryInstance->isDirectory($dir)) {
         foreach ($directoryInstance->readRecursively($dir) as $path) {
             $itemName = basename($path);
             if ($itemName == '.svn' || $itemName == '.htaccess') {
                 continue;
             }
             if ($directoryInstance->isDirectory($path)) {
                 $directories[] = array('name' => $itemName, 'path' => dirname($path) == '.' ? '/' : dirname($path));
             } else {
                 $files[] = $path;
             }
         }
     }
     return array('files' => $files, 'directories' => $directories);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:26,代码来源:File.php


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