本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::lastModified方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::lastModified方法的具体用法?PHP Filesystem::lastModified怎么用?PHP Filesystem::lastModified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::lastModified方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lastModified
/**
* Return the last modified timestamp of a view.
*
* @param string $name
* @return integer
* @throws FileNotFoundException
*/
public function lastModified($name)
{
if (!$this->files->exists($name)) {
throw new FileNotFoundException("{$name} does not exist");
}
return $this->files->lastModified($name);
}
示例2: get
public function get($path, array $data = array())
{
$filename = $this->files->name($path) . '.' . $this->files->extension($path);
$compile_path = \Config::get('view.compiled') . DIRECTORY_SEPARATOR . $filename;
$template_last_modified = $this->files->lastModified($path);
$cache_last_modified = $this->files->isFile($compile_path) ? $this->files->lastModified($compile_path) : $template_last_modified;
$view = $this->files->get($path);
$app = app();
// $m = new Mustache_Engine($app['config']->get('handlelars'));
// Configuration
$cache_disabled = false;
$helpers = \Config::get('handlelars.helpers');
// Precompile templates to view cache when necessary
$compile = $template_last_modified >= $cache_last_modified || $cache_disabled;
if ($compile) {
$tpl = LightnCandy::compile($view, compact('helpers'));
$this->files->put($compile_path, $tpl);
}
if (isset($data['__context']) && is_object($data['__context'])) {
$data = $data['__context'];
} else {
$data = array_map(function ($item) {
return is_object($item) && method_exists($item, 'toArray') ? $item->toArray() : $item;
}, $data);
}
$renderer = $this->files->getRequire($compile_path);
return $renderer($data);
}
示例3: isExpired
/**
* Determine if the view at the given path is expired.
*
* @param string $path
* @return bool
*/
public function isExpired($path)
{
$compiled = $this->getCompiledPath($path);
// If the compiled file doesn't exist we will indicate that the view is expired
// so that it can be re-compiled. Else, we will verify the last modification
// of the views is less than the modification times of the compiled views.
if (!$this->cachePath || !$this->files->exists($compiled)) {
return true;
}
$lastModified = $this->files->lastModified($path);
return $lastModified >= $this->files->lastModified($compiled);
}
示例4: getLastModified
/**
* Get the last modified time of the asset.
*
* @return int
*/
public function getLastModified()
{
if ($this->lastModified) {
return $this->lastModified;
}
return $this->lastModified = $this->isRemote() ? null : $this->files->lastModified($this->absolutePath);
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// 从数据库中获取的ArticleTag集合
$tags = \App\Model\Tag::all();
// 初始化博客的路径
$dir = "/root/blog";
$file_system = new Filesystem();
$files = $file_system->allFiles($dir);
foreach ($files as $file) {
$file_extension = $file_system->extension($file);
if ($file_extension != 'md') {
continue;
}
$create_time_stamp = $file_system->lastModified($file);
$create_time = gmdate("Y-m-d", $create_time_stamp);
$file_content = $file_system->get($file);
$file_name = preg_replace('/^.+[\\\\\\/]/', '', $file);
$file_name = explode(".md", $file_name);
$blog_name = $file_name[0];
$last_dir = dirname($file);
$current_tag_name = preg_replace('/^.+[\\\\\\/]/', '', $last_dir);
$article_type_id = 0;
foreach ($tags as $tag) {
$tag_name = $tag->name;
if (strcmp($current_tag_name, $tag_name) == 0) {
$article_type_id = $tag->id;
break;
}
}
$article_id = \App\Model\Article::create(['cate_id' => $article_type_id, 'user_id' => 1, 'title' => $blog_name, 'content' => $file_content, 'tags' => $article_type_id, 'created_at' => $create_time, 'updated_at' => $create_time])->id;
\App\Model\ArticleStatus::create(['art_id' => $article_id, 'view_number' => 0]);
}
}
示例6: createUndoFile
/**
* Creates the undo file
*
* @return void
*/
protected function createUndoFile()
{
// The generated files
$generatedFiles = [];
// Scan folders for generated files
foreach (['app', 'database/migrations'] as $folder) {
// For every file inside this folder
foreach ($this->filesystem->files($folder) as $file) {
// If lastModified time of this file is greater or equal to $this->startTime
if ($this->filesystem->lastModified($file) >= $this->startTime) {
// Add this file to our generated files array
$generatedFiles[] = $file;
}
}
}
// If we do not have any generated files
if (empty($generatedFiles)) {
// Show error message and end method execution
$this->error('No generated files created');
return;
}
// Output generated files to console
$this->info("The following files have been created:");
foreach ($generatedFiles as $generatedFile) {
$this->info(" {$generatedFile}");
}
// Save $generatedFiles to undo file if directory is writeable
if ($this->filesystem->isWritable($this->filePathDirectory)) {
// Write undo json file
$this->filesystem->put($this->undoFilePath, json_encode($generatedFiles, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
} else {
// Show error that file could not be created
$this->error('Could not create undo file, not enough permissions perhaps?: ' . $this->undoFilePath);
}
}
示例7: lastModified
/**
* Run a delete statement against the datasource.
*
* @param string $dirName
* @param string $fileName
* @return int
*/
public function lastModified($dirName, $fileName, $extension)
{
try {
$path = $this->makeFilePath($dirName, $fileName, $extension);
return $this->files->lastModified($path);
} catch (Exception $ex) {
return null;
}
}
示例8: isExpired
/**
* Determine if the view at the given path is expired.
*
* @param string $path
* @param array $attributes
*
* @return bool
*/
public function isExpired($path, array $attributes = [])
{
$compiled = $this->getCompiledPath($path, $attributes);
if (!$this->files->exists($compiled)) {
return true;
}
$lastModified = $this->files->lastModified($path);
return $lastModified >= $this->files->lastModified($compiled);
}
示例9: cleanOldPreviews
/**
* Delete previews older than the given life time configuration.
*
* @return void
*/
private function cleanOldPreviews()
{
$oldPreviews = array_filter($this->files->files($this->previewPath), function ($file) {
return time() - $this->files->lastModified($file) > $this->lifeTime;
});
if ($oldPreviews) {
$this->files->delete($oldPreviews);
}
}
示例10: getView
/**
* get view.
*
* @param string $slug
*
* @return string
*/
public function getView($slug)
{
$attributes = $this->getAttributes($slug);
$file = $this->storagePath() . md5($slug) . '.blade.php';
if ($this->filesystem->exists($file) === false || $attributes->updated_at->getTimestamp() > $this->filesystem->lastModified($file)) {
$this->filesystem->put($file, $attributes->content);
}
return $this->viewNamespace . '::' . md5($slug);
}
示例11: cleanOldPreviews
/**
* Delete previews older than the given life time configuration.
*/
private function cleanOldPreviews()
{
$oldPreviews = array_filter($this->files->files($this->storage()), function ($file) {
return time() - $this->files->lastModified($file) > Config::get('mail-debug.lifetime') * 60;
});
if ($oldPreviews) {
$this->files->delete($oldPreviews);
}
}
示例12: getOldFiles
/**
* 取得遺骸檔案列表.
*
* @param string $directory
* @return array
*/
protected function getOldFiles($directory)
{
$semester = intval(substr($this->semester, -1));
$now = Carbon::createFromDate(intval(substr($this->semester, 0, -1)) + (1 === $semester ? 1911 : 1912), 1 === $semester ? 10 : 3)->timestamp;
$files = [];
foreach ($this->filesystem->files($directory) as $file) {
if ($now - $this->filesystem->lastModified($file) > 12960000) {
$files[] = $file;
}
}
return $files;
}
示例13: clearRepository
/**
* Clear out all the old releases in a repository.
*
* @param string $repository
*
* @return void
*/
protected function clearRepository($repository)
{
foreach ($this->files->directories($repository) as $release) {
if ($this->files->lastModified($release) > $this->deletable) {
continue;
}
$this->files->deleteDirectory($release);
}
foreach ($this->files->files($repository) as $release) {
if ($this->files->lastModified($release) > $this->deletable) {
continue;
}
$this->files->delete($release);
}
}
示例14: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$tag_array = array();
$first_add = true;
$dir = "/root/blog";
$file_system = new Filesystem();
$files = $file_system->allFiles($dir);
foreach ($files as $file) {
$file_extension = $file_system->extension($file);
if ($file_extension != 'md') {
continue;
}
$last_dir = dirname($file);
$tag_name = preg_replace('/^.+[\\\\\\/]/', '', $last_dir);
$create_time_stamp = $file_system->lastModified($file);
$create_time = gmdate("Y-m-d", $create_time_stamp);
if ($first_add) {
$tag_info = array();
$tag_info[0] = $tag_name;
$tag_info[1] = $create_time;
$tag_array[0] = $tag_info;
$first_add = false;
}
$is_new = true;
foreach ($tag_array as $tag) {
if (strcmp($tag[0], $tag_name) == 0) {
$is_new = false;
}
}
if ($is_new) {
$tag_count = count($tag_array);
$tag_info = array();
$tag_info[0] = $tag_name;
$tag_info[1] = $create_time;
$tag_array[$tag_count] = $tag_info;
}
}
foreach ($tag_array as $tag_io) {
\App\Model\Tag::create(['name' => $tag_io[0]]);
\App\Model\Category::create(['cate_name' => $tag_io[0], 'as_name' => $tag_io[0], 'parent_id' => 0, 'seo_key' => $tag_io[0], 'seo_desc' => $tag_io[0], 'created_at' => $tag_io[1], 'updated_at' => $tag_io[1]]);
}
}
示例15: media
/**
* media.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Filesystem\Filesystem $filesystem
* @param \Illuminate\Contracts\Routing\ResponseFactory $request
* @param string $file
*
* @return \Illuminate\Http\Response
*/
public function media(Request $request, Filesystem $filesystem, ResponseFactory $responseFactory, $file)
{
$filename = __DIR__ . '/../../../public/' . $file;
$mimeType = strpos($filename, '.css') !== false ? 'text/css' : 'application/javascript';
$lastModified = $filesystem->lastModified($filename);
$eTag = sha1_file($filename);
$headers = ['content-type' => $mimeType, 'last-modified' => date('D, d M Y H:i:s ', $lastModified) . 'GMT'];
if (@strtotime($request->server('HTTP_IF_MODIFIED_SINCE')) === $lastModified || trim($request->server('HTTP_IF_NONE_MATCH'), '"') === $eTag) {
$response = $responseFactory->make(null, 304, $headers);
} else {
$response = $responseFactory->stream(function () use($filename) {
$out = fopen('php://output', 'wb');
$file = fopen($filename, 'rb');
stream_copy_to_stream($file, $out, filesize($filename));
fclose($out);
fclose($file);
}, 200, $headers);
}
return $response->setEtag($eTag);
}