From bba877a00a40494b1583d92b2090b39389b08723 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 18 Feb 2022 10:14:59 +0200 Subject: [PATCH] Added `FileInterface::touch()` method --- CHANGELOG.md | 2 ++ system/src/Grav/Framework/File/AbstractFile.php | 9 +++++++++ .../src/Grav/Framework/File/Interfaces/FileInterface.php | 9 +++++++++ 3 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c95664dca..f703d6f2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # v1.7.99-feature ## mm/dd/2022 +1. [](#new) + * Added `FileInterface::touch()` method 2. [](#improved) * By default, add media to only pages which have been initialized in pages loop diff --git a/system/src/Grav/Framework/File/AbstractFile.php b/system/src/Grav/Framework/File/AbstractFile.php index b216ea6c8..ff7864af5 100644 --- a/system/src/Grav/Framework/File/AbstractFile.php +++ b/system/src/Grav/Framework/File/AbstractFile.php @@ -341,6 +341,15 @@ class AbstractFile implements FileInterface return @unlink($this->filepath); } + /** + * {@inheritdoc} + * @see FileInterface::touch() + */ + public function touch(int $mtime = null): bool + { + return @touch($this->filepath, $mtime); + } + /** * @param string $dir * @return bool diff --git a/system/src/Grav/Framework/File/Interfaces/FileInterface.php b/system/src/Grav/Framework/File/Interfaces/FileInterface.php index f2cc288a9..a55e22607 100644 --- a/system/src/Grav/Framework/File/Interfaces/FileInterface.php +++ b/system/src/Grav/Framework/File/Interfaces/FileInterface.php @@ -177,4 +177,13 @@ interface FileInterface extends Serializable * @api */ public function delete(): bool; + + /** + * Touch file in the filesystem. + * + * @param int|null $mtime + * @return bool Returns `true` if the file was successfully touched, `false` otherwise. + * @api + */ + public function touch(int $mtime = null): bool; }