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


PHP Write::isFile方法代码示例

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


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

示例1: _getDefaultValue

 /**
  * Return content of default robot.txt
  *
  * @return bool|string
  */
 protected function _getDefaultValue()
 {
     if ($this->_directory->isFile($this->_file)) {
         return $this->_directory->readFile($this->_file);
     }
     return false;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:Robots.php

示例2: getFilesCollection

 /**
  * Get files collection
  *
  * @return array
  */
 public function getFilesCollection()
 {
     $paths = $this->mediaWriteDirectory->search('.*', $this->_helper->getCurrentPath());
     $files = [];
     $requestParams = $this->_helper->getRequestParams();
     $storageType = $this->_helper->getStorageType();
     foreach ($paths as $path) {
         if (!$this->mediaWriteDirectory->isFile($path)) {
             continue;
         }
         $fileName = pathinfo($path, PATHINFO_BASENAME);
         $file = ['text' => $fileName, 'id' => $this->urlEncoder->encode($fileName)];
         if (self::TYPE_IMAGE == $storageType) {
             $requestParams['file'] = $fileName;
             $file['thumbnailParams'] = $requestParams;
             $size = @getimagesize($path);
             if (is_array($size)) {
                 $file['width'] = $size[0];
                 $file['height'] = $size[1];
             }
         }
         $files[] = $file;
     }
     return $files;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:30,代码来源:Storage.php

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

示例4: __construct

 /**
  * Constructor
  *
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param string|null $destination
  * @throws \Magento\Framework\Model\Exception
  */
 public function __construct(\Magento\Framework\App\Filesystem $filesystem, $destination = null)
 {
     $this->_directoryHandle = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::SYS_TMP_DIR);
     if (!$destination) {
         $destination = uniqid('importexport_');
         $this->_directoryHandle->touch($destination);
     }
     if (!is_string($destination)) {
         throw new \Magento\Framework\Model\Exception(__('Destination file path must be a string'));
     }
     if (!$this->_directoryHandle->isWritable()) {
         throw new \Magento\Framework\Model\Exception(__('Destination directory is not writable'));
     }
     if ($this->_directoryHandle->isFile($destination) && !$this->_directoryHandle->isWritable($destination)) {
         throw new \Magento\Framework\Model\Exception(__('Destination file is not writable'));
     }
     $this->_destination = $destination;
     $this->_init();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:26,代码来源:AbstractAdapter.php

示例5: __construct

 /**
  * Constructor
  *
  * @param Filesystem $filesystem
  * @param string|null $destination
  * @param string $destinationDirectoryCode
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function __construct(\Magento\Framework\Filesystem $filesystem, $destination = null, $destinationDirectoryCode = DirectoryList::SYS_TMP)
 {
     $this->_directoryHandle = $filesystem->getDirectoryWrite($destinationDirectoryCode);
     if (!$destination) {
         $destination = uniqid('importexport_');
         $this->_directoryHandle->touch($destination);
     }
     if (!is_string($destination)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The destination file path must be a string.'));
     }
     if (!$this->_directoryHandle->isWritable()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The destination directory is not writable.'));
     }
     if ($this->_directoryHandle->isFile($destination) && !$this->_directoryHandle->isWritable($destination)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Destination file is not writable'));
     }
     $this->_destination = $destination;
     $this->_init();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:27,代码来源:AbstractAdapter.php


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