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


PHP Filesystem::getAdapter方法代码示例

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


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

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

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

示例3: preUpload

 /**
  * Update attachment entity before upload
  *
  * @param File $entity
  */
 public function preUpload(File $entity)
 {
     if ($entity->isEmptyFile()) {
         if ($entity->getFilename() !== null && $this->filesystem->has($entity->getFilename())) {
             $this->filesystem->delete($entity->getFilename());
         }
         $entity->setFilename(null);
         $entity->setExtension(null);
         $entity->setOriginalFilename(null);
     }
     if ($entity->getFile() !== null && $entity->getFile()->isFile()) {
         $entity->setOwner($this->securityFacadeLink->getService()->getLoggedUser());
         $file = $entity->getFile();
         if ($entity->getFilename() !== null && $this->filesystem->has($entity->getFilename())) {
             $this->filesystem->delete($entity->getFilename());
         }
         $entity->setExtension($file->guessExtension());
         if ($file instanceof UploadedFile) {
             $entity->setOriginalFilename($file->getClientOriginalName());
             $entity->setMimeType($file->getClientMimeType());
             $entity->setFileSize($file->getClientSize());
         } else {
             $entity->setOriginalFilename($file->getFileName());
             $entity->setMimeType($file->getMimeType());
             $entity->setFileSize($file->getSize());
         }
         $entity->setFilename($this->generateFileName($entity->getExtension()));
         $fsAdapter = $this->filesystem->getAdapter();
         if ($fsAdapter instanceof MetadataSupporter) {
             $fsAdapter->setMetadata($entity->getFilename(), ['contentType' => $entity->getMimeType()]);
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:38,代码来源:AttachmentManager.php

示例4: array

 /**
  * @param \Gaufrette\Filesystem $filesystem
  * @param \spec\Gaufrette\MetadataAdapter $adapter
  */
 function it_sets_content_of_file($filesystem, $adapter)
 {
     $adapter->setMetadata('filename', array())->shouldNotBeCalled();
     $filesystem->getAdapter()->willReturn($adapter);
     $filesystem->write('filename', 'some content', true)->shouldBeCalled()->willReturn(21);
     $this->setContent('some content')->shouldReturn(21);
     $this->getContent('filename')->shouldReturn('some content');
 }
开发者ID:RicardoSantosDiaz,项目名称:Gaufrette,代码行数:12,代码来源:FileSpec.php

示例5: __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

示例6: removeMedia

 /**
  * @param Media $media
  */
 public function removeMedia(Media $media)
 {
     $adapter = $this->fileSystem->getAdapter();
     # Remove the file from filesystem
     $fileKey = $this->getFilePath($media);
     if ($adapter->exists($fileKey)) {
         $adapter->delete($fileKey);
     }
     # Remove the files containing folder if there's nothing left
     $folderPath = $this->getFileFolderPath($media);
     if ($adapter->exists($folderPath) && $adapter->isDirectory($folderPath) && !empty($folderPath)) {
         $allMyKeys = $adapter->keys();
         $everythingfromdir = preg_grep('/' . $folderPath, $allMyKeys);
         if (count($everythingfromdir) === 1) {
             $adapter->delete($folderPath);
         }
     }
     $media->setRemovedFromFileSystem(true);
 }
开发者ID:bakie,项目名称:KunstmaanBundlesCMS,代码行数:22,代码来源:FileHandler.php

示例7: push

 /**
  * Push a local image/variation to the remote.
  *
  * If it is not hydrated this function will throw an exception
  *
  * @param Image $image
  * @param bool  $overwrite
  *
  * @return $this
  *
  * @throws ImageManagerException
  * @throws ObjectAlreadyExistsException
  * @throws \Exception
  */
 public function push(Image $image, $overwrite = true)
 {
     if (!$image->isHydrated() && $image instanceof ImageVariation) {
         // A pull on a variation will check if the variation exists, if not create it
         $this->pull($image);
     }
     if (!$image->isHydrated()) {
         throw new ImageManagerException(self::ERR_NOT_HYDRATED);
     }
     if (!$overwrite && $this->tagExists($image->getKey()) === true) {
         throw new ObjectAlreadyExistsException(self::ERR_ALREADY_EXISTS);
     }
     $adapter = $this->filesystem->getAdapter();
     if ($adapter instanceof MetadataSupporter) {
         $metadata = [];
         if ($image->getMimeType()) {
             // Set image ContentType on remote filesystem
             $metadata['ContentType'] = $image->getMimeType();
         }
         $adapter->setMetadata($image->getKey(), $metadata);
     }
     // Retrieve source image metadata
     $metadata = null;
     if (!$image instanceof ImageVariation) {
         $image_manipulation = new ImageInspector();
         $metadata = $image_manipulation->getImageMetadata($image);
     }
     try {
         $this->filesystem->write($image->getKey(), $image->getData(), $overwrite);
         $image->__friendSet('persistent', true);
         $this->tag($image->getKey(), $metadata);
     } catch (FileAlreadyExists $e) {
         $this->tag($image->getKey(), $metadata);
         throw new ObjectAlreadyExistsException(self::ERR_ALREADY_EXISTS);
     }
     return $this;
 }
开发者ID:bravo3,项目名称:image-manager,代码行数:51,代码来源:ImageManager.php

示例8: isDirectory

 /**
  * Whether this filesystem has an existing directory at the given path.
  * 
  * @param string $path The path to the directory, relative to this filesystem.
  * 
  * @return boolean
  */
 private function isDirectory($path)
 {
     $adapter = $this->gaufrette->getAdapter();
     return $adapter->isDirectory($this->getGaufrettePath($path));
 }
开发者ID:ibou77,项目名称:elgg,代码行数:12,代码来源:GaufretteDirectory.php

示例9: 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();
     }
 }
开发者ID:sasedev,项目名称:acf-expert,代码行数:65,代码来源:VfsController.php

示例10: __construct

 public function __construct(\Iterator $iterator, $regex, Filesystem $fs)
 {
     parent::__construct($iterator);
     $this->regex = $regex;
     $this->fsAdapter = $fs->getAdapter();
 }
开发者ID:lebris,项目名称:karma,代码行数:6,代码来源:FileFilterIterator.php

示例11: iCallMethodOfCurrentAdapter

 /**
  * @When I call method :method of current fs adapter
  */
 public function iCallMethodOfCurrentAdapter($method)
 {
     $method = new \ReflectionMethod($this->filesystem->getAdapter(), $method);
     $this->methodOutput = $method->invoke($this->filesystem->getAdapter());
 }
开发者ID:akovalyov,项目名称:gaufrette-integration-tests,代码行数:8,代码来源:FeatureContext.php

示例12: getLastModified

 /**
  * {@inheritdoc}
  */
 public function getLastModified()
 {
     return $this->filesystem->getAdapter()->mtime($this->prefix);
 }
开发者ID:bartv2,项目名称:SecotrustSabreDavBundle,代码行数:7,代码来源:Collection.php


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