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

PHP App\Filesystem类代码示例

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

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



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

示例1: 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


示例2: __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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:Download.php


示例3: __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


示例4: 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());
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:FileManager.php


示例5: __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);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:File.php


示例6: __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


示例7: __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


示例8: __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


示例9: __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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:Storage.php


示例10: __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);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:AbstractModel.php


示例11: 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


示例12: __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


示例13: __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'));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:14,代码来源:Collection.php


示例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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:Cron.php


示例15: 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


示例16: __construct

 /**
  * Construct
  *
  * @param \Magento\Framework\App\Helper\Context $context
  * @param \Magento\Backend\Helper\Data $backendData
  * @param \Magento\Core\Helper\Data $coreData
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Framework\StoreManagerInterface $storeManager
  */
 public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Backend\Helper\Data $backendData, \Magento\Core\Helper\Data $coreData, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\StoreManagerInterface $storeManager)
 {
     parent::__construct($context);
     $this->_backendData = $backendData;
     $this->_coreData = $coreData;
     $this->_storeManager = $storeManager;
     $this->_directory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
     $this->_directory->create(\Magento\Cms\Model\Wysiwyg\Config::IMAGE_DIRECTORY);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:18,代码来源:Images.php


示例17: __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);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:18,代码来源:Extension.php


示例18: __construct

 /**
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param \Magento\Framework\View\Design\Theme\FileFactory $fileFactory
  * @param \Magento\Core\Model\Layout\Link $link
  * @param \Magento\Core\Model\Layout\UpdateFactory $updateFactory
  * @param \Magento\Framework\Event\ManagerInterface $eventManager
  * @param \Magento\Framework\View\Design\Theme\Customization\Path $customization
  */
 public function __construct(\Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\View\Design\Theme\FileFactory $fileFactory, \Magento\Core\Model\Layout\Link $link, \Magento\Core\Model\Layout\UpdateFactory $updateFactory, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\View\Design\Theme\Customization\Path $customization)
 {
     $this->_directory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
     $this->_fileFactory = $fileFactory;
     $this->_link = $link;
     $this->_updateFactory = $updateFactory;
     $this->_eventManager = $eventManager;
     $this->_customizationPath = $customization;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:CopyService.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP App\ObjectManager类代码示例发布时间:2022-05-23
下一篇:
PHP App\DeploymentConfig类代码示例发布时间: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