当前位置: 首页>>代码示例>>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;未经允许,请勿转载。