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


PHP FilesystemInterface::getTimestamp方法代码示例

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


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

示例1: setHeaders

 /**
  * Set the streamed response headers.
  * @param  StreamedResponse $response The response object.
  * @return StreamedResponse
  */
 public function setHeaders(StreamedResponse $response)
 {
     $response->headers->set('Content-Type', $this->cache->getMimetype($this->path));
     $response->headers->set('Content-Length', $this->cache->getSize($this->path));
     $response->setPublic();
     $response->setMaxAge(31536000);
     $response->setExpires(date_create()->modify('+1 years'));
     $response->setLastModified(date_create()->setTimestamp($this->cache->getTimestamp($this->path)));
     $response->isNotModified($this->request);
     return $response;
 }
开发者ID:awebc,项目名称:web_xbf,代码行数:16,代码来源:ResponseFactory.php

示例2: _stat

 /**
  * Return stat for given path.
  * Stat contains following fields:
  * - (int)    size    file size in b. required
  * - (int)    ts      file modification time in unix time. required
  * - (string) mime    mimetype. required for folders, others - optionally
  * - (bool)   read    read permissions. required
  * - (bool)   write   write permissions. required
  * - (bool)   locked  is object locked. optionally
  * - (bool)   hidden  is object hidden. optionally
  * - (string) alias   for symlinks - link target path relative to root path. optionally
  * - (string) target  for symlinks - link target path. optionally
  *
  * If file does not exists - returns empty array or false.
  *
  * @param  string  $path    file path
  * @return array|false
  **/
 protected function _stat($path)
 {
     $stat = array('mime' => 'directory', 'ts' => time(), 'read' => true, 'write' => true, 'locked' => false, 'hidden' => false, 'size' => 0);
     // If root, just return from above
     if ($this->root == $path) {
         $stat['name'] = $this->root;
         return $stat;
     }
     // If not exists, return empty
     if (!$this->fs->has($path)) {
         return array();
     }
     $meta = $this->fs->getMetadata($path);
     // Get timestamp/size
     $stat['ts'] = isset($meta['timestamp']) ? $meta['timestamp'] : $this->fs->getTimestamp($path);
     $stat['size'] = isset($meta['size']) ? $meta['size'] : $this->fs->getSize($path);
     // Check if file, if so, check mimetype
     if ($meta['type'] == 'file') {
         $stat['mime'] = isset($meta['mimetype']) ? $meta['mimetype'] : $this->fs->getMimetype($path);
         $imgMimes = ['image/jpeg', 'image/png', 'image/gif'];
         if ($this->urlBuilder && in_array($stat['mime'], $imgMimes)) {
             $stat['url'] = $this->urlBuilder->getUrl($path, ['ts' => $stat['ts']]);
             $stat['tmb'] = $this->urlBuilder->getUrl($path, ['ts' => $stat['ts'], 'w' => $this->tmbSize, 'h' => $this->tmbSize, 'fit' => $this->options['tmbCrop'] ? 'crop' : 'contain']);
         }
     }
     if (!isset($stat['url']) && $this->fs->getUrl()) {
         $stat['url'] = 1;
     }
     return $stat;
 }
开发者ID:quepasso,项目名称:dashboard,代码行数:48,代码来源:ElFinderVolumeFlysystem.php

示例3: push

 /**
  * {@inheritdoc}
  */
 public function push(BackupInterface $backup)
 {
     $backupDirectory = $backup->getName();
     if (!$this->flysystem->has($backupDirectory) && !$this->flysystem->createDir($backupDirectory)) {
         throw new DestinationException(sprintf('Unable to create backup directory "%s" in flysystem destination.', $backupDirectory));
     }
     $removedBackupFiles = $this->getFiles($backupDirectory);
     /**
      * @var FileInterface $backupFile
      */
     foreach ($backup->getFiles() as $backupFile) {
         if (isset($removedBackupFiles[$backupFile->getRelativePath()])) {
             unset($removedBackupFiles[$backupFile->getRelativePath()]);
         }
         $path = $backupDirectory . '/' . $backupFile->getRelativePath();
         try {
             if ($this->flysystem->has($path)) {
                 if ($backupFile->getModifiedAt() > new \DateTime('@' . $this->flysystem->getTimestamp($path))) {
                     $resource = fopen($backupFile->getPath(), 'r');
                     $this->flysystem->updateStream($path, $resource);
                     fclose($resource);
                 }
             } else {
                 $resource = fopen($backupFile->getPath(), 'r');
                 $this->flysystem->putStream($path, $resource);
                 fclose($resource);
             }
         } catch (\Exception $e) {
             throw new DestinationException(sprintf('Unable to backup file "%s" to flysystem destination.', $backupFile->getPath()), 0, $e);
         }
     }
     /**
      * @var FileInterface $removedBackupFile
      */
     foreach ($removedBackupFiles as $removedBackupFile) {
         $path = $backupDirectory . '/' . $removedBackupFile->getRelativePath();
         try {
             $this->flysystem->delete($path);
         } catch (\Exception $e) {
             throw new DestinationException(sprintf('Unable to cleanup backup destination "%s" after backup process, file "%s" could not be removed.', $backupDirectory, $path), 0, $e);
         }
     }
     $this->removeEmptyDirectories($backupDirectory);
     if (is_array($this->backups)) {
         $this->backups[$backup->getName()] = $backup;
     }
 }
开发者ID:runopencode,项目名称:backup,代码行数:50,代码来源:FlysystemDestination.php

示例4: getTimestamp

 /**
  * @override
  * @inheritDoc
  */
 public function getTimestamp($path)
 {
     try {
         return $this->fs->getTimestamp($path);
     } catch (Error $ex) {
     } catch (Exception $ex) {
     }
     throw new ReadException("File {$path} timestamp could not be determined.", $ex);
 }
开发者ID:kraken-php,项目名称:framework,代码行数:13,代码来源:Filesystem.php

示例5:

 function it_can_remove_old_backups(FilesystemInterface $filesystem)
 {
     $files = [['path' => '.gitignore'], ['path' => 'foo.sql'], ['path' => 'foo1.sql'], ['path' => 'foo2.sql'], ['path' => 'foo3.sql'], ['path' => 'foo4.sql'], ['path' => 'foo5.sql'], ['path' => 'foo6.sql']];
     $filesystem->listFiles()->willReturn($files);
     $filesystem->getTimestamp('foo.sql')->willReturn(10000);
     $filesystem->getTimestamp('foo1.sql')->willReturn(500);
     $filesystem->getTimestamp('foo2.sql')->willReturn(10000);
     $filesystem->getTimestamp('foo3.sql')->willReturn(10000);
     $filesystem->getTimestamp('foo4.sql')->willReturn(100);
     $filesystem->getTimestamp('.gitignore')->willReturn(50);
     $filesystem->getTimestamp('foo5.sql')->willReturn(10000);
     $filesystem->getTimestamp('foo6.sql')->willReturn(10000);
     $filesystem->delete('foo1.sql')->shouldBeCalled();
     $filesystem->delete('foo4.sql')->shouldBeCalled();
     $this->removeOldBackups(5)->shouldReturn(['foo4.sql', 'foo1.sql']);
 }
开发者ID:ricoa,项目名称:laravel.io,代码行数:16,代码来源:BackupCleanerSpec.php

示例6: _stat

 /**
  * Return stat for given path.
  * Stat contains following fields:
  * - (int)    size    file size in b. required
  * - (int)    ts      file modification time in unix time. required
  * - (string) mime    mimetype. required for folders, others - optionally
  * - (bool)   read    read permissions. required
  * - (bool)   write   write permissions. required
  * - (bool)   locked  is object locked. optionally
  * - (bool)   hidden  is object hidden. optionally
  * - (string) alias   for symlinks - link target path relative to root path. optionally
  * - (string) target  for symlinks - link target path. optionally
  *
  * If file does not exists - returns empty array or false.
  *
  * @param  string  $path    file path
  * @return array|false
  **/
 protected function _stat($path)
 {
     $stat = array('size' => 0, 'ts' => time(), 'read' => true, 'write' => true, 'locked' => false, 'hidden' => false, 'mime' => 'directory');
     // If root, just return from above
     if ($this->root == $path) {
         $stat['name'] = $this->root;
         return $stat;
     }
     // If not exists, return empty
     if (!$this->fs->has($path)) {
         // Check if the parent doesn't have this path
         if ($this->_dirExists($path)) {
             return $stat;
         }
         // Neither a file or directory exist, return empty
         return array();
     }
     $meta = $this->fs->getMetadata($path);
     // getMetadata() on failure
     if (!$meta) {
         return array();
     }
     // Set item filename.extension to `name` if exists
     if (isset($meta['filename']) && isset($meta['extension'])) {
         $stat['name'] = $meta['filename'];
         if ($meta['extension'] !== '') {
             $stat['name'] .= '.' . $meta['extension'];
         }
     }
     // Get timestamp/size
     $stat['ts'] = isset($meta['timestamp']) ? $meta['timestamp'] : $this->fs->getTimestamp($path);
     $stat['size'] = isset($meta['size']) ? $meta['size'] : $this->fs->getSize($path);
     // Check if file, if so, check mimetype
     if ($meta['type'] == 'file') {
         $stat['mime'] = isset($meta['mimetype']) ? $meta['mimetype'] : $this->fs->getMimetype($path);
         $imgMimes = ['image/jpeg', 'image/png', 'image/gif'];
         if ($this->urlBuilder && in_array($stat['mime'], $imgMimes)) {
             $stat['url'] = $this->urlBuilder->getUrl($path, ['ts' => $stat['ts']]);
             $stat['tmb'] = $this->urlBuilder->getUrl($path, ['ts' => $stat['ts'], 'w' => $this->tmbSize, 'h' => $this->tmbSize, 'fit' => $this->options['tmbCrop'] ? 'crop' : 'contain']);
         }
     }
     if (!isset($stat['url']) && $this->fs->getUrl()) {
         $stat['url'] = 1;
     }
     return $stat;
 }
开发者ID:nao-pon,项目名称:elfinder-flysystem-driver,代码行数:64,代码来源:Driver.php

示例7: lastModified

 /**
  * Get the file's last modification time.
  *
  * @param  string  $path
  * @return int
  */
 public function lastModified($path)
 {
     return $this->driver->getTimestamp($path);
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:10,代码来源:FilesystemAdapter.php

示例8: sortFilesByCreationDate

 /**
  * @param \Illuminate\Support\Collection $files
  * @return \Illuminate\Support\Collection
  */
 private function sortFilesByCreationDate($files)
 {
     return $files->sortBy(function ($file) {
         return $this->filesystem->getTimestamp($file['path']);
     });
 }
开发者ID:ricoa,项目名称:laravel.io,代码行数:10,代码来源:BackupCleaner.php

示例9: getTimestamp

 /**
  * Get a file's timestamp.
  *
  * @param string $path The path to the file.
  *
  * @throws FileNotFoundException
  *
  * @return string|false The timestamp or false on failure.
  */
 public function getTimestamp($path)
 {
     return $this->fileSystem->getTimestamp($path);
 }
开发者ID:graze,项目名称:data-file,代码行数:13,代码来源:FilesystemWrapper.php


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