本文整理汇总了PHP中Gaufrette\Filesystem类的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem类的具体用法?PHP Filesystem怎么用?PHP Filesystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Filesystem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: let
function let(Filesystem $filesystem, ImageInterface $image)
{
$filesystem->has(Argument::any())->willReturn(false);
$file = new File(__FILE__, 'img.jpg');
$image->getFile()->willReturn($file);
$this->beConstructedWith($filesystem);
}
开发者ID:Silwereth,项目名称:Sylius,代码行数:7,代码来源:ImageUploaderSpec.php
示例3:
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
示例4: 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
示例5: 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
示例6: __construct
public function __construct(Filesystem $filesystem, $bufferSize, $streamWrapperPrefix, $prefix)
{
if (!$filesystem->getAdapter() instanceof StreamFactory) {
throw new \InvalidArgumentException('The filesystem used as chunk storage must implement StreamFactory');
}
$this->filesystem = $filesystem;
$this->bufferSize = $bufferSize;
$this->prefix = $prefix;
$this->streamWrapperPrefix = $streamWrapperPrefix;
}
开发者ID:lsv,项目名称:OneupUploaderBundle,代码行数:10,代码来源:GaufretteStorage.php
示例7:
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
示例8: 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
示例9: testCache
public function testCache()
{
$cacheAdapter = new InMemory(array());
$this->app['finder.cache.adapter'] = $cacheAdapter;
$cache = new Filesystem($cacheAdapter);
$this->assertEmpty($cache->keys());
// exec without cache
$this->runCommand('rollback', array('sourcePath' => 'src/'));
$this->assertEmpty($cache->keys());
// exec with cache
$this->runCommand('rollback', array('--cache' => true, 'sourcePath' => 'src/'));
$this->assertNotEmpty($cache->keys());
}
开发者ID:niktux,项目名称:karma,代码行数:13,代码来源:RollbackCommandTest.php
示例10: 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
示例11:
function it_archives_unvalid_items(InvalidItemsCollector $collector, CsvWriter $writer, JobExecution $jobExecution, JobInstance $jobInstance, Filesystem $filesystem)
{
$collector->getInvalidItems()->willReturn(['items']);
$jobExecution->getId()->willReturn('id');
$jobExecution->getJobInstance()->willReturn($jobInstance);
$jobInstance->getType()->willReturn('type');
$jobInstance->getAlias()->willReturn('alias');
$filesystem->write('type/alias/id/invalid/invalid_items.csv', '', true)->shouldBeCalled();
$writer->setFilePath('/root/type/alias/id/invalid/invalid_items.csv')->shouldBeCalled();
$writer->initialize()->shouldBeCalled();
$writer->write(['items'])->shouldBeCalled();
$writer->flush()->shouldBeCalled();
$this->archive($jobExecution);
}
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:14,代码来源:InvalidItemsCsvArchiverSpec.php
示例12: clearCache
/**
* {@inheritDoc}
*/
public function clearCache($maxAge)
{
$delTime = time() - (int) $maxAge;
$num = 0;
foreach ($this->temporaryFilesystem->keys() as $key) {
if (!$this->temporaryFilesystem->getAdapter()->isDirectory($key)) {
if ($delTime > $this->temporaryFilesystem->mtime($key)) {
$this->temporaryFilesystem->delete($key);
$num++;
}
}
}
return $num;
}
开发者ID:thrace-project,项目名称:media-bundle,代码行数:17,代码来源:AbstractManager.php
示例13: LocalAdapter
function it_create_a_file_when_reader_is_valid(CsvReader $reader, JobExecution $jobExecution, JobInstance $jobInstance, Job $job, ItemStep $step, $filesystem)
{
$jobExecution->getJobInstance()->willReturn($jobInstance);
$jobExecution->getId()->willReturn(12);
$jobInstance->getJob()->willReturn($job);
$jobInstance->getType()->willReturn('type');
$jobInstance->getAlias()->willReturn('alias');
$job->getSteps()->willReturn([$step]);
$step->getReader()->willReturn($reader);
$reader->getFilePath()->willReturn('/tmp/tmp');
$adapter = new LocalAdapter('/tmp');
$fs = new Filesystem($adapter);
$fs->write('tmp', '', true);
$filesystem->write("type/alias/12/input/tmp", "", true)->shouldBeCalled();
$this->archive($jobExecution);
}
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:16,代码来源:FileReaderArchiverSpec.php
示例14: testResize
public function testResize()
{
$image = $this->getMock('Imagine\\Image\\ImageInterface');
$image->expects($this->once())->method('thumbnail')->will($this->returnValue($image));
$image->expects($this->once())->method('get')->will($this->returnValue(file_get_contents(__DIR__ . '/../fixtures/logo.png')));
$adapter = $this->getMock('Imagine\\Image\\ImagineInterface');
$adapter->expects($this->any())->method('load')->will($this->returnValue($image));
$media = $this->getMock('Sonata\\MediaBundle\\Model\\MediaInterface');
$media->expects($this->exactly(2))->method('getBox')->will($this->returnValue(new Box(535, 132)));
$filesystem = new Filesystem(new InMemory());
$in = $filesystem->get('in', true);
$in->setContent(file_get_contents(__DIR__ . '/../fixtures/logo.png'));
$out = $filesystem->get('out', true);
$resizer = new SimpleResizer($adapter, 'outbound');
$resizer->resize($media, $in, $out, 'bar', array('height' => null, 'width' => 90, 'quality' => 100));
}
开发者ID:novatex,项目名称:SonataMediaBundle,代码行数:16,代码来源:SimpleResizerTest.php
示例15: 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
示例16: 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
示例17: getArchive
/**
* {@inheritdoc}
*/
public function getArchive(JobExecution $jobExecution, $key)
{
$archives = $this->getArchives($jobExecution);
if (!isset($archives[$key])) {
throw new \InvalidArgumentException(sprintf('Key "%s" does not exist', $key));
}
return $this->filesystem->createStream($archives[$key]);
}
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:11,代码来源:AbstractFilesystemArchiver.php
示例18: 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
示例19: deleteFile
/**
* delete the given file
*
* @param string $file
*/
public function deleteFile($file)
{
if (!$this->filesystem->has($file)) {
return;
}
$this->filesystem->delete($file);
$this->cacheManager->remove($file);
}
开发者ID:CampaignChain,项目名称:core,代码行数:13,代码来源:FileUploadService.php
示例20: testRemoveAFileIfMediaIsRemoved
/**
* Test related method
*/
public function testRemoveAFileIfMediaIsRemoved()
{
$this->filesystem->expects($this->any())->method('has')->will($this->returnValue(true));
$this->filesystem->expects($this->once())->method('delete');
$media = $this->getMediaMock();
$media->expects($this->any())->method('isRemoved')->will($this->returnValue(true));
$media->expects($this->any())->method('getFilename')->will($this->returnValue('foo.jpg'));
$this->manager->handle($media, '');
}
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:12,代码来源:MediaManagerTest.php
注:本文中的Gaufrette\Filesystem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论