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


PHP Write::isReadable方法代码示例

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


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

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

示例2: loadPackagesForUpdateFromCache

 /**
  * Load composer packages available for update from cache
  *
  * @return bool|string
  */
 private function loadPackagesForUpdateFromCache()
 {
     if ($this->directory->isExist($this->pathToCacheFile) && $this->directory->isReadable($this->pathToCacheFile)) {
         try {
             $data = $this->directory->readFile($this->pathToCacheFile);
             return json_decode($data, true);
         } catch (\Magento\Framework\Exception\FileSystemException $e) {
         }
     }
     return false;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:UpdatePackagesCache.php

示例3: _createThumbnail

 /**
  * Create thumbnail for image and save it to thumbnails directory
  *
  * @param string $source
  * @return bool|string Resized filepath or false if errors were occurred
  */
 public function _createThumbnail($source)
 {
     if (self::TYPE_IMAGE != $this->_helper->getStorageType() || !$this->mediaWriteDirectory->isFile($source) || !$this->mediaWriteDirectory->isReadable($source)) {
         return false;
     }
     $thumbnailDir = $this->_helper->getThumbnailDirectory($source);
     $thumbnailPath = $thumbnailDir . '/' . pathinfo($source, PATHINFO_BASENAME);
     try {
         $this->mediaWriteDirectory->isExist($thumbnailDir);
         $image = $this->_imageFactory->create();
         $image->open($this->mediaWriteDirectory->getAbsolutePath($source));
         $image->keepAspectRatio(true);
         $image->resize(self::THUMBNAIL_WIDTH, self::THUMBNAIL_HEIGHT);
         $image->save($this->mediaWriteDirectory->getAbsolutePath($thumbnailPath));
     } catch (\Magento\Framework\Exception\FileSystemException $e) {
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
         return false;
     }
     if ($this->mediaWriteDirectory->isFile($thumbnailPath)) {
         return $thumbnailPath;
     }
     return false;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:29,代码来源:Storage.php


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