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


PHP SplFileInfo::getMTime方法代码示例

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


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

示例1: parse

 /**
  * @param      $string
  * @param null $path
  * @return string
  */
 public function parse($string, $path = null)
 {
     $headers = [];
     $parts = preg_split('/[\\n]*[-]{3}[\\n]/', $string, 3);
     if (count($parts) == 3) {
         $string = $parts[0] . "\n" . $parts[2];
         $headers = $this->yaml->parse($parts[1]);
     }
     $file = new SplFileInfo($path, '', '');
     $date = Carbon::createFromTimestamp($file->getMTime());
     $dateFormat = config('fizl-pages::date_format', 'm/d/Y g:ia');
     $headers['date_modified'] = $date->toDateTimeString();
     if (isset($headers['date'])) {
         try {
             $headers['date'] = Carbon::createFromFormat($dateFormat, $headers['date'])->toDateTimeString();
         } catch (\InvalidArgumentException $e) {
             $headers['date'] = $headers['date_modified'];
             //dd($e->getMessage());
         }
     } else {
         $headers['date'] = $headers['date_modified'];
     }
     $this->execute(new PushHeadersIntoCollectionCommand($headers, $this->headers));
     $viewPath = PageHelper::filePathToViewPath($path);
     $cacheKey = "{$viewPath}.headers";
     $this->cache->put($cacheKey, $headers);
     return $string;
 }
开发者ID:hscale,项目名称:fizl-pages,代码行数:33,代码来源:PageHeaderParser.php

示例2: getDate

 /**
  * Front matter date or filemtime
  *
  * @return DateTime
  */
 public function getDate()
 {
     if (false === $this->frontMatter->has('date')) {
         # Defaults to last modified
         return (new DateTime())->setTimestamp($this->file->getMTime());
     }
     $date = $this->frontMatter->getDate();
     if ($date instanceof DateTime) {
         return $date;
     }
     return (new DateTime())->setTimestamp($date);
 }
开发者ID:jtallant,项目名称:skimpy-engine,代码行数:17,代码来源:ContentFile.php

示例3: updateContent

 public function updateContent(SplFileInfo $fileInfo)
 {
     $pathname = $this->getAttribute('pathname');
     $process = new Process("diff {$pathname} {$fileInfo->getPathname()}", storage_path('pigeon'));
     $process->run();
     $output = $process->getOutput();
     preg_match_all('/^>\\s*(.*)/mix', $output, $matches);
     if ($matches) {
         $newText = implode("\n", $matches[1]);
         app('files')->append(storage_path('pigeon') . '/' . $pathname, "\n" . $newText);
         $this->setAttribute('modified_at', $fileInfo->getMTime());
     }
 }
开发者ID:vansanblch,项目名称:pigeon-hunt,代码行数:13,代码来源:Files.php

示例4: getInfo

 /**
  * Get ID3 info from a file.
  *
  * @param SplFileInfo $file
  *
  * @return array|null
  */
 public function getInfo(SplFileInfo $file)
 {
     $info = $this->getID3->analyze($file->getPathname());
     if (isset($info['error'])) {
         return;
     }
     // Copy the available tags over to comment.
     // This is a helper from getID3, though it doesn't really work well.
     // We'll still prefer getting ID3v2 tags directly later.
     // Read on.
     getid3_lib::CopyTagsToComments($info);
     $props = ['artist' => '', 'album' => '', 'title' => '', 'length' => $info['playtime_seconds'], 'lyrics' => '', 'cover' => array_get($info, 'comments.picture', [null])[0], 'path' => $file->getPathname(), 'mtime' => $file->getMTime()];
     if (!($comments = array_get($info, 'comments_html'))) {
         return $props;
     }
     // We prefer id3v2 tags over others.
     if (!($artist = array_get($info, 'tags.id3v2.artist', [null])[0])) {
         $artist = array_get($comments, 'artist', [''])[0];
     }
     if (!($album = array_get($info, 'tags.id3v2.album', [null])[0])) {
         $album = array_get($comments, 'album', [''])[0];
     }
     if (!($title = array_get($info, 'tags.id3v2.title', [null])[0])) {
         $title = array_get($comments, 'title', [''])[0];
     }
     if (!($lyrics = array_get($info, 'tags.id3v2.unsynchronised_lyric', [null])[0])) {
         $lyrics = array_get($comments, 'unsynchronised_lyric', [''])[0];
     }
     $props['artist'] = trim($artist);
     $props['album'] = trim($album);
     $props['title'] = trim($title);
     $props['lyrics'] = trim($lyrics);
     return $props;
 }
开发者ID:Holdlen2DH,项目名称:koel,代码行数:41,代码来源:Media.php

示例5:

 function it_should_filter_by_date(SplFileInfo $file1, SplFileInfo $file2)
 {
     $file1->isFile()->willReturn(true);
     $file2->isFile()->willReturn(true);
     $file1->getRealPath()->willReturn($this->tempFile);
     $file2->getRealPath()->willReturn($this->tempFile);
     $file1->getMTime()->willReturn(strtotime('-4 hours'));
     $file2->getMTime()->willReturn(strtotime('-5 days'));
     $result = $this->date('since yesterday');
     $result->shouldBeAnInstanceOf('GrumPHP\\Collection\\FilesCollection');
     $result->count()->shouldBe(1);
     $files = $result->toArray();
     $files[0]->shouldBe($file1);
 }
开发者ID:kientrunghuynh,项目名称:grumphp,代码行数:14,代码来源:FilesCollectionSpec.php

示例6: getModifiedTime

 private function getModifiedTime(SplFileInfo $file)
 {
     $dt = new \DateTime();
     $dt->setTimestamp($file->getMTime());
     return $dt->format(\DateTime::ISO8601);
 }
开发者ID:spress,项目名称:spress,代码行数:6,代码来源:FilesystemDataSource.php

示例7: fileInfo

 /**
  * Todas las propiedades de un archivo o directorio
  * 
  * @param SplFileInfo $file Object of SplFileInfo
  * @param string $path Ruta de la carpeta o archivo
  * @return array|null Lista de propiedades o null si no es leible
  */
 public function fileInfo($file, $path)
 {
     if ($file->isReadable()) {
         $item = $this->fileDetails;
         $item["filename"] = $file->getFilename();
         $item["filetype"] = $file->getExtension();
         $item["lastmodified"] = $file->getMTime();
         $item["size"] = $file->getSize();
         if ($file->isDir()) {
             $item["filetype"] = '';
             $item["isdir"] = true;
             $item["urlfolder"] = $path . $item["filename"] . '/';
             $item['preview'] = '';
         } elseif ($file->isFile()) {
             $thumb = $this->createThumb($file, $path);
             if ($thumb) {
                 $item['preview'] = $this->config['url'] . $this->config['source'] . '/_thumbs' . $path . $thumb;
             }
             $item['previewfull'] = $this->config['url'] . $this->config['source'] . $path . $item["filename"];
         }
         return $item;
     } else {
         return;
     }
 }
开发者ID:guillermomartinez,项目名称:filemanager-php,代码行数:32,代码来源:Filemanager.php

示例8: extractStringTokens

 /**
  * Extract all strings from a given file.
  *
  * @param SplFileInfo $file
  *
  * @return string[]
  */
 protected function extractStringTokens(SplFileInfo $file)
 {
     // Fetch tokens from cache if available
     $hash = 'janitor.tokens.' . md5($file->getPathname()) . '-' . $file->getMTime();
     return $this->cache->rememberForever($hash, function () use($file) {
         $contents = $file->getContents();
         // See if we have an available Tokenizer
         // and use it to extract the contents
         switch ($file->getExtension()) {
             case 'php':
                 $tokenizer = strpos($file->getBasename(), 'blade.php') !== false ? new BladeTokenizer() : new PhpTokenizer();
                 break;
             case 'twig':
                 $tokenizer = new TwigTokenizer();
                 break;
             case 'json':
                 $tokenizer = new JsonTokenizer();
                 break;
             case 'yml':
             case 'yaml':
                 $tokenizer = new YamlTokenizer();
                 break;
             case 'xml':
                 $tokenizer = new XmlTokenizer();
                 break;
             default:
                 $tokenizer = new DefaultTokenizer();
                 break;
         }
         return $tokenizer->tokenize($contents);
     });
 }
开发者ID:anahkiasen,项目名称:janitor,代码行数:39,代码来源:Codebase.php

示例9: getMTime

 public function getMTime()
 {
     return $this->fileInfo->getMTime();
 }
开发者ID:phramz,项目名称:doctrine-annotation-scanner,代码行数:4,代码来源:ClassFileInfo.php


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