當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。