本文整理汇总了PHP中Gaufrette\Filesystem::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::get方法的具体用法?PHP Filesystem::get怎么用?PHP Filesystem::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gaufrette\Filesystem
的用法示例。
在下文中一共展示了Filesystem::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPrivateKeyResource
/**
* @return resource
*/
private function getPrivateKeyResource()
{
try {
$file = $this->filesystem->get($this->fileName);
} catch (FileNotFound $e) {
$file = $this->createKeys();
}
$key = openssl_pkey_get_private($file->getContent());
return $key;
}
示例2: getChild
/**
* {@inheritdoc}
*/
public function getChild($name)
{
$key = $this->prefix . $name;
if (!$this->filesystem->has($key)) {
throw new Exception\NotFound('The file with name: ' . $name . ' could not be found');
}
if ($this->filesystem->getAdapter()->isDirectory($key)) {
return new self($this->filesystem, $key . '/');
}
return new File($this->filesystem->get($key));
}
示例3: validateEmailAttachmentForTargetClass
/**
* Validate file by target entity without saving.
*
* @param EmailAttachment $emailAttachment
* @param string $className
*
* @return \Symfony\Component\Validator\ConstraintViolationListInterface
*/
public function validateEmailAttachmentForTargetClass(EmailAttachment $emailAttachment, $className)
{
if (null === $emailAttachment->getFile()) {
$file = $this->copyEmailAttachmentToFileSystem($emailAttachment);
$fileViolations = $this->configFileValidator->validate($className, $file);
$this->filesystem->get($file->getFilename())->delete();
} else {
$file = $emailAttachment->getFile();
$fileViolations = $this->configFileValidator->validate($className, $file);
}
return $fileViolations;
}
示例4: oroToEntity
/**
* @param AttachmentOro $attachmentOro
*
* @return AttachmentEntity
*/
public function oroToEntity(AttachmentOro $attachmentOro)
{
$emailAttachmentEntity = new AttachmentEntity();
$emailAttachmentEntity->setFileName($attachmentOro->getFile()->getFilename());
$emailAttachmentContent = new EmailAttachmentContent();
$emailAttachmentContent->setContent(base64_encode($this->filesystem->get($attachmentOro->getFile()->getFilename())->getContent()));
$emailAttachmentContent->setContentTransferEncoding('base64');
$emailAttachmentContent->setEmailAttachment($emailAttachmentEntity);
$emailAttachmentEntity->setContent($emailAttachmentContent);
$emailAttachmentEntity->setContentType($attachmentOro->getFile()->getMimeType());
$emailAttachmentEntity->setFile($attachmentOro->getFile());
$emailAttachmentEntity->setFileName($attachmentOro->getFile()->getOriginalFilename());
return $emailAttachmentEntity;
}
示例5: testGetThrowsAnExceptionIfTheFileDoesNotExistAndTheCreateParameterIsSetToFalse
public function testGetThrowsAnExceptionIfTheFileDoesNotExistAndTheCreateParameterIsSetToFalse()
{
$adapter = new InMemory();
$fs = new Filesystem($adapter);
$this->setExpectedException('InvalidArgumentException');
$fs->get('myFile');
}
示例6: 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));
}
示例7: getOriginalFile
/**
* @param Media $media
*
* @return \Gaufrette\File
*/
public function getOriginalFile(Media $media)
{
$relativePath = sprintf('/%s.%s', $media->getUuid(), ExtensionGuesser::getInstance()->guess($media->getContentType()));
return $this->fileSystem->get($relativePath, true);
}
示例8: getOriginalFile
/**
* @param Media $media
*
* @return \Gaufrette\File
*/
public function getOriginalFile(Media $media)
{
return $this->fileSystem->get($this->getFilePath($media), true);
}
示例9: getJson
/**
* @return string
*/
public function getJson()
{
return $this->filesystem->has($this->configFile) ? $this->filesystem->get($this->configFile, true)->getContent() : '{}';
}
示例10: getContent
/**
* Get file content
*
* @param File|string $file The File object or file name
*
* @return string
*/
public function getContent($file)
{
return $this->filesystem->get($file instanceof File ? $file->getFilename() : $file)->getContent();
}
示例11: getContent
/**
* Get file content
*
* @param File $entity
* @return string
*/
public function getContent(File $entity)
{
return $this->filesystem->get($entity->getFilename())->getContent();
}
示例12: fileAction
/**
* Get Virtual Files Action
*
* @param string $file
*
* @throws NotFoundHttpException
* @return Response
*/
public function fileAction($file = null)
{
if (null == $file) {
return $this->redirect($this->generateUrl('vfs_files', array('file' => '/')));
}
$cacheDirectory = $this->getParameter('adapter_cache_dir');
$local = new LocalAdapter($cacheDirectory, true);
$localadapter = new LocalAdapter($this->getParameter('adapter_files'));
$adapter = new CacheAdapter($localadapter, $local, 3600);
$fsAvatar = new Filesystem($adapter);
if ($this->endswith($file, '/')) {
if ($fsAvatar->has($file)) {
$this->gvars['title'] = $this->translate('indexof', array('%dir%' => $this->generateUrl('vfs_files', array('file' => $file))));
$this->gvars['pagetitle'] = $this->translate('indexof_raw', array('%dir%' => $this->generateUrl('vfs_files', array('file' => $file))));
$path = substr($file, 1);
$fs = $fsAvatar->listKeys($path);
$listfiles = array();
foreach ($fs['dirs'] as $key) {
$fulldir = $key . '/';
$dirname = $key;
if (substr($key, 0, strlen($path)) == $path) {
$dirname = substr($dirname, strlen($path));
}
if (!strstr($dirname, '/')) {
$listfiles[$fulldir] = $dirname;
}
}
foreach ($fs['keys'] as $key) {
$fullfile = $key;
$filename = $key;
if (substr($key, 0, strlen($path)) == $path) {
$filename = substr($filename, strlen($path));
}
if (!strstr($filename, '/')) {
$listfiles[$fullfile] = $filename;
}
}
$this->gvars['fs'] = $listfiles;
return $this->renderResponse('AcfResBundle:Vfs:list_files.html.twig', $this->gvars);
} else {
throw new NotFoundHttpException();
}
}
if ($fsAvatar->has($file)) {
if ($fsAvatar->getAdapter()->isDirectory($file)) {
$file .= '/';
return $this->redirect($this->generateUrl('vfs_files', array('file' => $file)));
}
$reqFile = $fsAvatar->get($file);
$response = new Response();
$response->headers->set('Content-Type', 'binary');
$response->setContent($reqFile->getContent());
return $response;
} else {
throw new NotFoundHttpException();
}
}
示例13: get
/**
* Get file.
*
* @param $name
* @return File
*/
public function get($name)
{
return $this->filesystem->get($name);
}
示例14: getImage
/**
* Returns raw image.
*
* @param string $imagePath
*
* @return string
*/
public function getImage($imagePath)
{
return $this->files->get($imagePath)->getContent();
}
示例15: move
/**
* Move file to external filesystem
*
* @param Filesystem $filesystem File system to store file. If omitted - store in php's upload_tmp_dir
* @param string $targetFilename New file name. If omitted - use original filename
* @return \Gaufrette\File
*/
public function move(Filesystem $filesystem = null, $targetFilename = null, $overwrite = true)
{
// source file
$sourceFile = $this->getTransport()->getFile();
// target base name
$targetBasename = $this->buildTargetBasename($sourceFile, $targetFilename);
// move file to target storage
$content = stream_get_contents($sourceFile->getStream());
// write file
$filesystem->write($targetBasename, $content, $overwrite);
return $filesystem->get($targetBasename);
}