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


PHP Filesystem::read方法代码示例

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


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

示例1: read

 /**
  * @return mixed
  */
 public function read()
 {
     if (!$this->gaufrette->has($this->filePath)) {
         return '';
     }
     return $this->gaufrette->read($this->filePath);
 }
开发者ID:raphhh,项目名称:balloon,代码行数:10,代码来源:GaufretteAdapter.php

示例2: showAction

 /**
  * @param Request $request
  * @param string  $filename
  *
  * @throws NotFoundHttpException If media is not found
  *
  * @return Response
  */
 public function showAction(Request $request, $filename)
 {
     if (!$this->filesystem->has($filename)) {
         throw new NotFoundHttpException(sprintf('Media "%s" not found', $filename));
     }
     $response = new Response($content = $this->filesystem->read($filename));
     $mime = $this->filesystem->mimeType($filename);
     if (($filter = $request->query->get('filter')) && null !== $mime && 0 === strpos($mime, 'image')) {
         try {
             $cachePath = $this->cacheManager->resolve($request, $filename, $filter);
             if ($cachePath instanceof Response) {
                 $response = $cachePath;
             } else {
                 $image = $this->imagine->load($content);
                 $response = $this->filterManager->get($request, $filter, $image, $filename);
                 $response = $this->cacheManager->store($response, $cachePath, $filter);
             }
         } catch (\RuntimeException $e) {
             if (0 === strpos($e->getMessage(), 'Filter not defined')) {
                 throw new HttpException(404, sprintf('The filter "%s" cannot be found', $filter), $e);
             }
             throw $e;
         }
     }
     if ($mime) {
         $response->headers->set('Content-Type', $mime);
     }
     return $response;
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:37,代码来源:MediaController.php

示例3: generateThumbnail

 /**
  * @param string $fileKey
  * @param string $fileKeyWithFormat
  * @param Format $format
  *
  * @return
  */
 protected function generateThumbnail($fileKey, $fileKeyWithFormat, Format $format)
 {
     // check if has original picture
     try {
         $has = $this->fileSystem->has($fileKey);
     } catch (\OutOfBoundsException $e) {
         $has = false;
     }
     if (!$has) {
         throw new Exception\ImageDoesNotExistException();
     }
     // create thumbnail
     try {
         $blobOriginal = $this->fileSystem->read($fileKey);
     } catch (FileNotFound $e) {
         throw new Exception\ImageDoesNotExistException();
     }
     $imagine = new Imagine();
     $image = $imagine->load($blobOriginal);
     $resizedImage = Manipulator::resize($image, $format);
     $extension = $this->getExtension($fileKey);
     $blobResizedImage = $resizedImage->get($extension, array('jpeg_quality' => 90, 'png_compression_level' => 9));
     $this->fileSystem->write($fileKeyWithFormat, $blobResizedImage, true);
     return $blobResizedImage;
 }
开发者ID:fvilpoix,项目名称:php-common,代码行数:32,代码来源:Resizator.php

示例4: getContents

 /** @inheritDoc */
 public function getContents($path)
 {
     try {
         return $this->gaufrette->read($this->getGaufrettePath($path));
     } catch (\Exception $e) {
         return '';
     }
 }
开发者ID:ibou77,项目名称:elgg,代码行数:9,代码来源:GaufretteDirectory.php

示例5: downloadFile

 /**
  * Given a Doctrine mapped File instance, retrieves its data and fill
  * content local variable with it.
  *
  * @param FileInterface $file File to download
  *
  * @return FileInterface File downloaded
  */
 public function downloadFile(FileInterface $file)
 {
     /**
      * @var string $content
      */
     $content = $this->filesystem->read($this->fileIdentifierTransformer->transform($file));
     $file->setContent($content);
     return $file;
 }
开发者ID:VictorMateo,项目名称:elcodi,代码行数:17,代码来源:FileManager.php

示例6:

 function it_saves_content_of_files_from_gaufrette_at_local_disk(Filesystem $filesystem)
 {
     $filesystem->listKeys('test')->willReturn(['keys' => ['test/aaa/z.txt', 'test/aaa/test2.txt', 'test.txt'], 'dirs' => ['test/aaa']]);
     $filesystem->read('test/aaa/z.txt')->willReturn('Some content');
     $filesystem->read('test/aaa/test2.txt')->willReturn('Other text content');
     $files = $this->getFiles('test');
     $files[0]->shouldBeAnInstanceOf('Cocoders\\FileSource\\File');
     $files[0]->shouldHaveContent('Some content');
     $files[1]->shouldBeAnInstanceOf('Cocoders\\FileSource\\File');
     $files[1]->shouldHaveContent('Other text content');
 }
开发者ID:partikus,项目名称:FileArchive,代码行数:11,代码来源:GaufretteFileSourceSpec.php

示例7: getFiles

 /**
  * @param $path
  * @return array|\Cocoders\FileSource\File[]
  */
 public function getFiles($path)
 {
     $listedKeys = $this->filesystem->listKeys($path);
     $files = [];
     foreach ($listedKeys['keys'] as $key) {
         $filePath = $this->tmpPath . '/' . $key;
         $this->createBaseDirectory($filePath);
         if ($this->isNotInRootDir($filePath)) {
             file_put_contents($filePath, $this->filesystem->read($key));
             $files[] = new File($filePath);
         }
     }
     return $files;
 }
开发者ID:partikus,项目名称:FileArchive,代码行数:18,代码来源:GaufretteFileSource.php

示例8: testReadThrowsAnExceptionIfTheKeyDoesNotMatchAnyFile

 public function testReadThrowsAnExceptionIfTheKeyDoesNotMatchAnyFile()
 {
     $adapter = new InMemory();
     $fs = new Filesystem($adapter);
     $this->setExpectedException('InvalidArgumentException');
     $fs->read('myFile');
 }
开发者ID:ruudk,项目名称:Gaufrette,代码行数:7,代码来源:FilesystemTest.php

示例9: read

 private function read(Filesystem $fs)
 {
     $profileFilename = Application::PROFILE_FILENAME;
     if ($fs->has($profileFilename)) {
         $this->processProfileContent($fs->read($profileFilename));
     }
 }
开发者ID:lebris,项目名称:karma,代码行数:7,代码来源:ProfileReader.php

示例10: pullVariation

 /**
  * Pull a variation image, if the variation does not exist, try pulling the source and creating the variation.
  *
  * @param ImageVariation $image
  *
  * @throws NotExistsException
  */
 protected function pullVariation(ImageVariation $image)
 {
     try {
         // First, check if the variation exists on the remote
         $this->pullSource($image);
     } catch (NotExistsException $e) {
         // Variation does not exist, try pulling the parent data and creating the variation
         try {
             $parent = new Image($image->getKey(true));
             if ($this->tagExists($image->getKey(true)) === false) {
                 if (!$this->validate_tags || !$this->validateTag($parent)) {
                     throw new NotExistsException(self::ERR_PARENT_NOT_EXISTS);
                 }
             }
             $data = $this->filesystem->read($image->getKey(true));
             // Resample
             $parent->setData($data);
             $this->hydrateVariation($parent, $image);
             $parent->flush();
         } catch (FileNotFoundException $e) {
             // No image exists
             throw new NotExistsException(self::ERR_PARENT_NOT_EXISTS);
         }
     }
 }
开发者ID:bravo3,项目名称:image-manager,代码行数:32,代码来源:ImageManager.php

示例11: load

 /**
  * {@inheritDoc}
  */
 public function load($path)
 {
     try {
         $contents = $this->filesystem->read($path);
     } catch (FileNotFoundException $e) {
         throw new Exception\ImageNotFoundException(sprintf('Source image not found in "%s"', $path));
     }
     try {
         $mimeType = $this->filesystem->mimeType($path);
     } catch (\LogicException $e) {
         // Mime Type could not be detected
         return $contents;
     }
     if (!$mimeType) {
         // Mime Type could not be detected
         return $contents;
     }
     return new Binary($contents, $mimeType);
 }
开发者ID:shitikovkirill,项目名称:zend-shop.com,代码行数:22,代码来源:GaufretteLoader.php

示例12: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $file = $input->getArgument('file');
     $filesystem = new Filesystem(new Local('/'));
     $titlerator = new Titlerator(new Transliterator(Settings::LANG_SR), $filesystem->read($file));
     $titlerator->fixEncoding();
     if ($input->getOption('transliterate')) {
         $titlerator->transliterate();
     }
     $filesystem->write($file, $titlerator->getText(), true);
 }
开发者ID:umpirsky,项目名称:titlerator,代码行数:11,代码来源:FixCommand.php

示例13: shouldRenameFile

 /**
  * @test
  * @group functional
  */
 public function shouldRenameFile()
 {
     $this->filesystem->write('foo', 'Some content');
     $this->filesystem->rename('foo', 'boo');
     $this->assertFalse($this->filesystem->has('foo'));
     $this->assertEquals('Some content', $this->filesystem->read('boo'));
     $this->filesystem->delete('boo');
     $this->filesystem->write('foo', 'Some content');
     $this->filesystem->rename('foo', 'somedir/sub/boo');
     $this->assertFalse($this->filesystem->has('somedir/sub/foo'));
     $this->assertEquals('Some content', $this->filesystem->read('somedir/sub/boo'));
     $this->filesystem->delete('somedir/sub/boo');
 }
开发者ID:course-hero,项目名称:gaufrette-extras,代码行数:17,代码来源:FunctionalTestCase.php

示例14: execute

 /**
  * @param string $targetPath
  * @param array $replacePatterns
  * @return mixed|void
  */
 public function execute($targetPath = '', array $replacePatterns = array())
 {
     $adapter = new LocalAdapter($targetPath);
     $filesystem = new Filesystem($adapter);
     $listKeys = $filesystem->listKeys();
     if (count($replacePatterns) > 0) {
         foreach ($listKeys['keys'] as $file) {
             if (!@strstr(mime_content_type($targetPath . $file), 'image') && !@strstr($file, '.git') && !@strstr($file, '.svn')) {
                 $filesystem->write($file, $this->replaceContent($replacePatterns, $filesystem->read($file)), TRUE);
             }
         }
     }
 }
开发者ID:kj187,项目名称:typo3-helper,代码行数:18,代码来源:RenameContentTask.php

示例15: getETag

 public function getETag($id)
 {
     if ($this->filesystem->has($id)) {
         return $this->filesystem->read($id . '.etag');
     }
 }
开发者ID:SethMcGathey,项目名称:html,代码行数:6,代码来源:GaufretteCache.php


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