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


PHP Write::create方法代码示例

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


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

示例1: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     /** @var \Magento\Framework\App\Filesystem $filesystem */
     $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\Filesystem');
     self::$_varDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
     self::$_tmpDir = self::$_varDirectory->getAbsolutePath('ConfigTest');
     self::$_varDirectory->create(self::$_varDirectory->getRelativePath(self::$_tmpDir));
 }
开发者ID:aiesh,项目名称:magento2,代码行数:8,代码来源:ConfigTest.php

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

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

示例4: _saveFatalErrorReport

 /**
  * Log information about fatal error.
  *
  * @param string $reportData
  * @return string
  */
 protected function _saveFatalErrorReport($reportData)
 {
     $this->directoryWrite->create('report/api');
     $reportId = abs(intval(microtime(true) * rand(100, 1000)));
     $this->directoryWrite->writeFile('report/api/' . $reportId, serialize($reportData));
     return $reportId;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:ErrorProcessor.php

示例5: check

 /**
  * Check var/generation read and write access
  *
  * @return bool
  */
 public function check()
 {
     $initParams = $this->serviceManager->get(InitParamListener::BOOTSTRAP_PARAM);
     $filesystemDirPaths = isset($initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS]) ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] : [];
     $directoryList = new DirectoryList(BP, $filesystemDirPaths);
     $generationDirectoryPath = $directoryList->getPath(DirectoryList::GENERATION);
     $driverPool = new DriverPool();
     $fileWriteFactory = new WriteFactory($driverPool);
     /** @var \Magento\Framework\Filesystem\DriverInterface $driver */
     $driver = $driverPool->getDriver(DriverPool::FILE);
     $directoryWrite = new Write($fileWriteFactory, $driver, $generationDirectoryPath);
     if ($directoryWrite->isExist()) {
         if ($directoryWrite->isDirectory() || $directoryWrite->isReadable()) {
             try {
                 $probeFilePath = $generationDirectoryPath . DIRECTORY_SEPARATOR . uniqid(mt_rand()) . 'tmp';
                 $fileWriteFactory->create($probeFilePath, DriverPool::FILE, 'w');
                 $driver->deleteFile($probeFilePath);
             } catch (\Exception $e) {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         try {
             $directoryWrite->create();
         } catch (\Exception $e) {
             return false;
         }
     }
     return true;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:37,代码来源:GenerationDirectoryAccess.php

示例6: resizeFile

 /**
  * Create thumbnail for image and save it to thumbnails directory
  *
  * @param string $source Image path to be resized
  * @param bool $keepRation Keep aspect ratio or not
  * @return bool|string Resized filepath or false if errors were occurred
  */
 public function resizeFile($source, $keepRation = true)
 {
     $realPath = $this->_directory->getRelativePath($source);
     if (!$this->_directory->isFile($realPath) || !$this->_directory->isExist($realPath)) {
         return false;
     }
     $targetDir = $this->getThumbsPath($source);
     $pathTargetDir = $this->_directory->getRelativePath($targetDir);
     if (!$this->_directory->isExist($pathTargetDir)) {
         $this->_directory->create($pathTargetDir);
     }
     if (!$this->_directory->isExist($pathTargetDir)) {
         return false;
     }
     $image = $this->_imageFactory->create();
     $image->open($source);
     $image->keepAspectRatio($keepRation);
     $image->resize($this->_resizeParameters['width'], $this->_resizeParameters['height']);
     $dest = $targetDir . '/' . pathinfo($source, PATHINFO_BASENAME);
     $image->save($dest);
     if ($this->_directory->isFile($this->_directory->getRelativePath($dest))) {
         return $dest;
     }
     return false;
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:32,代码来源:Storage.php

示例7: createPackageV1x

 /**
  * Create package file compatible with previous version of Magento Connect Manager
  *
  * @return boolean
  */
 public function createPackageV1x()
 {
     try {
         $this->writeDirectory->create('pear/');
     } catch (\Magento\Framework\Filesystem\FilesystemException $e) {
         $this->logger->addStreamLog(\Magento\Framework\Logger::LOGGER_EXCEPTION);
         $this->logger->log($e->getMessage());
         return false;
     }
     if (!$this->getPackageXml()) {
         $this->generatePackageXml();
     }
     $this->getPackage()->saveV1x($this->writeDirectory->getAbsolutePath('pear/'));
     return true;
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:20,代码来源:Extension.php

示例8: createFolder

 /**
  * Create folder
  *
  * @param string $name
  * @param string $path
  * @return array
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function createFolder($name, $path)
 {
     if (!preg_match(self::DIRECTORY_NAME_REGEXP, $name)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Use only standard alphanumeric, dashes and underscores.'));
     }
     if (!$this->mediaWriteDirectory->isWritable($path)) {
         $path = $this->_helper->getStorageRoot();
     }
     $newPath = $path . '/' . $name;
     if ($this->mediaWriteDirectory->isExist($newPath)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('We found a directory with the same name.'));
     }
     $this->mediaWriteDirectory->create($newPath);
     $result = ['name' => $name, 'short_name' => $this->_helper->getShortFilename($name), 'path' => str_replace($this->_helper->getStorageRoot(), '', $newPath), 'id' => $this->_helper->convertPathToId($newPath)];
     return $result;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:24,代码来源:Storage.php

示例9: getCurrentPath

 /**
  * Return path of the current selected directory or root directory for startup
  * Try to create target directory if it doesn't exist
  *
  * @return string
  * @throws \Magento\Framework\Model\Exception
  */
 public function getCurrentPath()
 {
     if (!$this->_currentPath) {
         $currentPath = $this->_directory->getAbsolutePath() . \Magento\Cms\Model\Wysiwyg\Config::IMAGE_DIRECTORY;
         $path = $this->_getRequest()->getParam($this->getTreeNodeName());
         if ($path) {
             $path = $this->convertIdToPath($path);
             if ($this->_directory->isDirectory($this->_directory->getRelativePath($path))) {
                 $currentPath = $path;
             }
         }
         try {
             $currentDir = $this->_directory->getRelativePath($currentPath);
             if (!$this->_directory->isExist($currentDir)) {
                 $this->_directory->create($currentDir);
             }
         } catch (\Magento\Framework\Filesystem\FilesystemException $e) {
             $message = __('The directory %1 is not writable by server.', $currentPath);
             throw new \Magento\Framework\Model\Exception($message);
         }
         $this->_currentPath = $currentPath;
     }
     return $this->_currentPath;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:31,代码来源:Images.php

示例10: testCreate

 public function testCreate()
 {
     $this->driver->expects($this->once())->method('isDirectory')->will($this->returnValue(false));
     $this->driver->expects($this->once())->method('createDirectory')->will($this->returnValue(true));
     $this->assertTrue($this->write->create('correct-path'));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:6,代码来源:WriteTest.php


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