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


PHP Filesystem::write方法代码示例

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


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

示例1:

 function it_uploads_all_files_to_gaufrette(Filesystem $filesystem)
 {
     $filesystem->write('myArchive/aaa/a.txt', 'Test Cocoders content 123')->shouldBeCalled();
     $filesystem->write('myArchive/aaa/t.txt', 'Test Cocoders content!')->shouldBeCalled();
     $filesystem->write('myArchive/bbb', 'CDE !')->shouldBeCalled();
     $this->upload('myArchive', [vfsStream::url('tmp/23a/aaa/a.txt'), vfsStream::url('tmp/23a/aaa/t.txt'), vfsStream::url('tmp/23a/bbb')]);
 }
开发者ID:partikus,项目名称:FileArchive,代码行数:7,代码来源:GaufretteUploadProviderSpec.php

示例2: upload

 public function upload($name, $paths)
 {
     $rootParent = $this->fetchRootPath($paths);
     foreach ($paths as $path) {
         $key = $this->generateKey($name, $rootParent, $path);
         $this->filesystem->write($key, file_get_contents($path));
     }
 }
开发者ID:partikus,项目名称:FileArchive,代码行数:8,代码来源:GaufretteUploadProvider.php

示例3: fileExistsWithContent

 /**
  * @Given file :name exists
  * @Given dir :name exists
  * @Given file :name exists with content:
  * @Given I write :name with content:
  */
 public function fileExistsWithContent($name, PyStringNode $string = null)
 {
     if (null === $string) {
         $this->filesystem->createFile($name);
     } else {
         $this->filesystem->write($name, $string->__toString(), true);
     }
 }
开发者ID:akovalyov,项目名称:gaufrette-integration-tests,代码行数:14,代码来源:FeatureContext.php

示例4: saveImage

 /**
  * Saves an image.
  *
  * @param string $path
  * @param string $image
  *
  * @return string
  */
 public function saveImage($image, $path = null)
 {
     if ($path == null) {
         $path = 'images/' . uniqid() . '.png';
     }
     $this->files->write($path, $image, true);
     return $path;
 }
开发者ID:Zylius,项目名称:GalerijaAPI,代码行数:16,代码来源:ImageStoreService.php

示例5: write

 /**
  * @param mixed $data
  * @param int $mode
  * @return int
  */
 public function write($data, $mode = 0)
 {
     if ($mode & FILE_APPEND) {
         $data = $this->read() . $data;
     }
     if (!$this->gaufrette->has($this->filePath)) {
         $this->gaufrette->createFile($this->filePath);
     }
     return $this->gaufrette->write($this->filePath, $data, true);
 }
开发者ID:raphhh,项目名称:balloon,代码行数:15,代码来源:GaufretteAdapter.php

示例6: store

 /**
  * Store a file content.
  *
  * @param  UploadContext $context
  * @param $content
  * @param  array         $metadataMap
  * @return UploadedFile
  */
 public function store(UploadContext $context, $content, array $metadataMap = array())
 {
     $name = $this->namingStrategy->getName($context);
     $directory = $this->storageStrategy->getDirectory($context, $name);
     $path = $directory . '/' . $name;
     $adapter = $this->filesystem->getAdapter();
     if ($adapter instanceof MetadataSupporter) {
         $adapter->setMetadata($path, $this->resolveMetadataMap($context, $metadataMap));
     }
     $this->filesystem->write($path, $content);
     $file = $this->filesystem->get($path);
     return new UploadedFile($this, $file);
 }
开发者ID:WeClipApp,项目名称:SRIORestUploadBundle,代码行数:21,代码来源:FileStorage.php

示例7: upload

 /**
  * {@inheritdoc}
  */
 public function upload(ImageInterface $image)
 {
     if (!$image->hasFile()) {
         return;
     }
     if (null !== $image->getPath()) {
         $this->remove($image->getPath());
     }
     do {
         $hash = md5(uniqid(mt_rand(), true));
         $path = $this->expandPath($hash . '.' . $image->getFile()->guessExtension());
     } while ($this->filesystem->has($path));
     $image->setPath($path);
     $this->filesystem->write($image->getPath(), file_get_contents($image->getFile()->getPathname()));
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:18,代码来源:ImageUploader.php

示例8: testWriteThrowsAnExceptionIfTheFileAlreadyExistsAndIsNotAllowedToOverwrite

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

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

示例10: LocalAdapter

 function it_duplicates_product_media($filesystem, ProductMediaInterface $source, ProductMediaInterface $target, File $newFile)
 {
     $target->setFile(Argument::any())->shouldBeCalled();
     $source->getOriginalFilename()->willReturn('akeneo.jpg');
     $target->getOriginalFilename()->willReturn('akeneo.jpg');
     // upload
     $target->getFile()->willReturn($newFile);
     $newFile->getPathname()->willReturn('/tmp/tmp-phpspec');
     // write a fake file in tmp
     $adapter = new LocalAdapter('/tmp');
     $fs = new Filesystem($adapter);
     $fs->write('tmp-phpspec', '', true);
     $source->getFilename()->willReturn('akeneo.jpg');
     $newFile->getFilename()->willReturn('akeneo.jpg');
     $filesystem->write('prefix-akeneo.jpg', '', false)->shouldBeCalled();
     $target->setOriginalFilename('akeneo.jpg')->shouldBeCalled();
     $target->setFilename('prefix-akeneo.jpg')->shouldBeCalled();
     $filesystem->has('akeneo.jpg')->willReturn(true);
     $target->getFilename()->willReturn('akeneo.jpg');
     $newFile->getMimeType()->willReturn('jpg');
     $target->setMimeType('jpg')->shouldBeCalled();
     // update original file name
     $source->getOriginalFilename()->willReturn('akeneo.jpg');
     $target->setOriginalFilename('akeneo.jpg')->shouldBeCalled();
     $this->duplicate($source, $target, 'prefix');
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:26,代码来源:MediaManagerSpec.php

示例11: shouldWorkWithHiddenFiles

 /**
  * @test
  * @group functional
  */
 public function shouldWorkWithHiddenFiles()
 {
     $this->filesystem->write('.foo', 'hidden');
     $this->assertTrue($this->filesystem->has('.foo'));
     $this->assertContains('.foo', $this->filesystem->keys());
     $this->filesystem->delete('.foo');
     $this->assertFalse($this->filesystem->has('.foo'));
 }
开发者ID:course-hero,项目名称:gaufrette-extras,代码行数:12,代码来源:FunctionalTestCase.php

示例12: run

 /**
  * Retrieve information about artist (TopAlbum and track of album)
  */
 public function run()
 {
     $result = $this->serviceArtistInfo->setArtist($this->artistName)->getResults();
     if (!isset($result->error)) {
         $artist = new Artist();
         $artist->setName($this->artistName)->setInfo($result->artist->bio->summary);
         if (!is_array($result->artist->tags->tag)) {
             $tags = array($result->artist->tags->tag);
         } else {
             $tags = $result->artist->tags->tag;
         }
         foreach ($tags as $tagResult) {
             $tag = new ArtistTagDocument();
             $tag->setName($tagResult->name);
             $artist->addTag($tag);
         }
         $albumResult = $this->serviceArtistAlbum->setArtist($this->artistName)->getResults();
         if (!isset($albumResult->error)) {
             if (!is_array($albumResult->topalbums->album)) {
                 $albums = array($albumResult->topalbums->album);
             } else {
                 $albums = $albumResult->topalbums->album;
             }
             foreach ($albums as $albumResult) {
                 $album = new ArtistAlbumDocument();
                 $album->setName($albumResult->name)->setMbid($albumResult->mbid);
                 if (is_array($albumResult->image)) {
                     $image = $albumResult->image[count($albumResult->image) - 1];
                     $var = '#text';
                     if ('' !== $image->{$var}) {
                         $fileName = substr($image->{$var}, strrpos($image->{$var}, '/'));
                         $this->fileSystem->write($fileName, file_get_contents($image->{$var}));
                         $album->setImage($fileName);
                     }
                 }
                 if ($albumResult->mbid) {
                     $albumInfoResult = $this->serviceAlbumInfo->setArtist($this->artistName)->setMbid($albumResult->mbid)->getResults();
                     if (!isset($albumInfoResult->error)) {
                         if (!is_array($albumInfoResult->album->tracks->track)) {
                             $tracks = array($albumInfoResult->album->tracks->track);
                         } else {
                             $tracks = $albumInfoResult->album->tracks->track;
                         }
                         foreach ($tracks as $trackResult) {
                             $track = new ArtistTrackDocument();
                             $track->setName($trackResult->name)->setDuration($trackResult->duration);
                             $album->addTrack($track);
                         }
                     }
                     $artist->addAlbum($album);
                 }
             }
         }
         $this->artistQuery->persist($artist);
     }
 }
开发者ID:cedric190985,项目名称:vidlis,代码行数:59,代码来源:Creator.php

示例13: upload

 /**
  * {@inheritdoc}
  */
 public function upload(MediaInterface $media, $name = null, $test = false)
 {
     if (!$media->hasMedia()) {
         return;
     }
     if (null !== $media->getName()) {
         $this->remove($media->getName());
     }
     do {
         $hash = md5(uniqid(mt_rand(), true));
         if ($test === false) {
             $name = $hash . '.' . $media->getMedia()->guessExtension();
         }
     } while ($this->filesystem->has($name));
     $media->setName($name);
     if ($test === false) {
         $this->filesystem->write($media->getName(), file_get_contents($media->getMedia()->getPathname()));
     }
 }
开发者ID:dasklney,项目名称:kreta,代码行数:22,代码来源:MediaUploader.php

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

示例15: shouldFetchKeys

 /**
  * @test
  * @group functional
  */
 public function shouldFetchKeys()
 {
     $this->assertEquals(array(), $this->filesystem->keys());
     $this->filesystem->write('foo', 'Some content');
     $this->filesystem->write('bar', 'Some content');
     $this->filesystem->write('baz', 'Some content');
     $actualKeys = $this->filesystem->keys();
     $this->assertEquals(3, count($actualKeys));
     foreach (array('foo', 'bar', 'baz') as $key) {
         $this->assertContains($key, $actualKeys);
     }
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:16,代码来源:FunctionalTestCase.php


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