當前位置: 首頁>>代碼示例>>PHP>>正文


PHP File::isReadable方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\File\File::isReadable方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::isReadable方法的具體用法?PHP File::isReadable怎麽用?PHP File::isReadable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpFoundation\File\File的用法示例。


在下文中一共展示了File::isReadable方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setFile

 /**
  * Sets the file to stream.
  *
  * @param \SplFileInfo|string $file               The file to stream
  * @param string              $contentDisposition
  * @param bool                $autoEtag
  * @param bool                $autoLastModified
  *
  * @return BinaryFileResponse
  *
  * @throws FileException
  */
 public function setFile($file, $contentDisposition = null, $etag = false, $lastModified = true)
 {
     if (!$file instanceof File) {
         if ($file instanceof \SplFileInfo) {
             $file = new File($file->getPathname());
         } else {
             $file = new File((string) $file);
         }
     }
     if (!$file->isReadable()) {
         throw new FileException('File must be readable.');
     }
     $this->file = $file;
     if ($etag === true) {
         $this->setAutoEtag();
     } elseif (!empty($etag)) {
         $this->setEtag($etag);
     }
     if ($lastModified === true) {
         $this->setAutoLastModified();
     } elseif (!empty($lastModified)) {
         is_numeric($lastModified) && ($lastModified = '@' . $lastModified);
         $this->setLastModified(new \DateTime($lastModified));
     }
     if ($contentDisposition) {
         $this->setContentDisposition($contentDisposition);
     }
     return $this;
 }
開發者ID:unionbt,項目名稱:hanpaimall,代碼行數:41,代碼來源:BinaryFileResponse.php

示例2: setFile

 /**
  * Sets the file to stream.
  *
  * @param \SplFileInfo|string $file The file to stream
  * @param string              $contentDisposition
  * @param Boolean             $autoEtag
  * @param Boolean             $autoLastModified
  *
  * @return BinaryFileResponse
  *
  * @throws FileException
  */
 public function setFile($file, $contentDisposition = null, $autoEtag = false, $autoLastModified = true)
 {
     $file = new File((string) $file);
     if (!$file->isReadable()) {
         throw new FileException('File must be readable.');
     }
     $this->file = $file;
     if ($autoEtag) {
         $this->setAutoEtag();
     }
     if ($autoLastModified) {
         $this->setAutoLastModified();
     }
     if ($contentDisposition) {
         $this->setContentDisposition($contentDisposition);
     }
     return $this;
 }
開發者ID:omusico,項目名稱:lafayettehelps.com,代碼行數:30,代碼來源:BinaryFileResponse.php

示例3: importInfinityBoardAssets

 /**
  * Imports board attachments.
  *
  * @return void
  */
 public function importInfinityBoardAssets()
 {
     $this->info("\tImporting board assets ...");
     BoardAsset::whereDoesntHave('flagPosts')->forceDelete();
     Board::orderBy('board_uri', 'asc')->chunk(1, function ($boards) {
         foreach ($boards as $board) {
             $this->line("\t\tImporting assets from /{$board->board_uri}/");
             $flagsMade = 0;
             $bannersMade = 0;
             # FLAGS
             $flagsPath = "{$this->targetLocation}/static/custom-flags/{$board->board_uri}/";
             $flagSerPath = "{$this->targetLocation}/{$board->board_uri}/flags.ser";
             $flags = [];
             if (file_exists($flagSerPath)) {
                 try {
                     $flags = @unserialize(@file_get_contents("{$this->targetLocation}/{$board->board_uri}/flags.ser"));
                 } catch (\Exception $e) {
                     $this->warn("\t\t\tFailed to unserialize flags.ser");
                 }
                 if (is_array($flags) && count($flags)) {
                     foreach ($flags as $flagFile => $flagName) {
                         $flag = new File("{$flagsPath}{$flagFile}.png", false);
                         if ($flag->isReadable()) {
                             $storage = FileStorage::storeUpload($flag);
                             $asset = $board->assets()->create(['file_id' => $storage->file_id, 'asset_type' => "board_flags", 'asset_name' => $flagName]);
                             ++$flagsMade;
                         }
                     }
                 }
             }
             # BANNERS
             $bannersPath = "{$this->targetLocation}/static/banners/{$board->board_uri}/";
             if (is_readable($bannersPath)) {
                 $banners = array_filter(scandir($bannersPath), function ($item) use($bannersPath) {
                     return !is_dir("{$bannersPath}{$item}");
                 });
                 foreach ($banners as $bannerName) {
                     $banner = new File("{$bannersPath}{$bannerName}", false);
                     if ($banner->isReadable() && !!FileFacade::get($banner)) {
                         $storage = FileStorage::storeUpload($banner);
                         $asset = $board->assets()->create(['file_id' => $storage->file_id, 'asset_type' => "board_banner", 'asset_name' => null]);
                         ++$bannersMade;
                     }
                 }
             }
             $this->line("\t\tImported {$flagsMade} flags and {$bannersMade} banners.");
         }
     });
 }
開發者ID:LulzNews,項目名稱:infinity-next,代碼行數:54,代碼來源:Import.php


注:本文中的Symfony\Component\HttpFoundation\File\File::isReadable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。