diff options
author | VirtualTam <virtualtam@flibidi.net> | 2018-12-02 23:24:58 +0100 |
---|---|---|
committer | VirtualTam <virtualtam@flibidi.net> | 2019-01-12 22:47:48 +0100 |
commit | bdc5152d486ca75372c271f94623b248bc127800 (patch) | |
tree | 45012b55c96215f83dc863882717822ce5aa9e25 /application | |
parent | 1826e383ecf501302974132fd443cf1ca06e10f6 (diff) | |
download | Shaarli-bdc5152d486ca75372c271f94623b248bc127800.tar.gz Shaarli-bdc5152d486ca75372c271f94623b248bc127800.tar.zst Shaarli-bdc5152d486ca75372c271f94623b248bc127800.zip |
namespacing: \Shaarli\History
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'application')
-rw-r--r-- | application/History.php | 13 | ||||
-rw-r--r-- | application/NetscapeBookmarkUtils.php | 1 | ||||
-rw-r--r-- | application/api/controllers/ApiController.php | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/application/History.php b/application/History.php index 35ec016a..8074a017 100644 --- a/application/History.php +++ b/application/History.php | |||
@@ -1,4 +1,9 @@ | |||
1 | <?php | 1 | <?php |
2 | namespace Shaarli; | ||
3 | |||
4 | use DateTime; | ||
5 | use Exception; | ||
6 | use FileUtils; | ||
2 | 7 | ||
3 | /** | 8 | /** |
4 | * Class History | 9 | * Class History |
@@ -141,7 +146,7 @@ class History | |||
141 | * Save a new event and write it in the history file. | 146 | * Save a new event and write it in the history file. |
142 | * | 147 | * |
143 | * @param string $status Event key, should be defined as constant. | 148 | * @param string $status Event key, should be defined as constant. |
144 | * @param mixed $id Event item identifier (e.g. link ID). | 149 | * @param mixed $id Event item identifier (e.g. link ID). |
145 | */ | 150 | */ |
146 | protected function addEvent($status, $id = null) | 151 | protected function addEvent($status, $id = null) |
147 | { | 152 | { |
@@ -166,11 +171,11 @@ class History | |||
166 | */ | 171 | */ |
167 | protected function check() | 172 | protected function check() |
168 | { | 173 | { |
169 | if (! is_file($this->historyFilePath)) { | 174 | if (!is_file($this->historyFilePath)) { |
170 | FileUtils::writeFlatDB($this->historyFilePath, []); | 175 | FileUtils::writeFlatDB($this->historyFilePath, []); |
171 | } | 176 | } |
172 | 177 | ||
173 | if (! is_writable($this->historyFilePath)) { | 178 | if (!is_writable($this->historyFilePath)) { |
174 | throw new Exception(t('History file isn\'t readable or writable')); | 179 | throw new Exception(t('History file isn\'t readable or writable')); |
175 | } | 180 | } |
176 | } | 181 | } |
@@ -191,7 +196,7 @@ class History | |||
191 | */ | 196 | */ |
192 | protected function write() | 197 | protected function write() |
193 | { | 198 | { |
194 | $comparaison = new DateTime('-'. $this->retentionTime . ' seconds'); | 199 | $comparaison = new DateTime('-' . $this->retentionTime . ' seconds'); |
195 | foreach ($this->history as $key => $value) { | 200 | foreach ($this->history as $key => $value) { |
196 | if ($value['datetime'] < $comparaison) { | 201 | if ($value['datetime'] < $comparaison) { |
197 | unset($this->history[$key]); | 202 | unset($this->history[$key]); |
diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php index 84dd2b20..c0c007ea 100644 --- a/application/NetscapeBookmarkUtils.php +++ b/application/NetscapeBookmarkUtils.php | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | use Psr\Log\LogLevel; | 3 | use Psr\Log\LogLevel; |
4 | use Shaarli\Config\ConfigManager; | 4 | use Shaarli\Config\ConfigManager; |
5 | use Shaarli\History; | ||
5 | use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser; | 6 | use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser; |
6 | use Katzgrau\KLogger\Logger; | 7 | use Katzgrau\KLogger\Logger; |
7 | 8 | ||
diff --git a/application/api/controllers/ApiController.php b/application/api/controllers/ApiController.php index 9edefcf6..47e0e178 100644 --- a/application/api/controllers/ApiController.php +++ b/application/api/controllers/ApiController.php | |||
@@ -30,7 +30,7 @@ abstract class ApiController | |||
30 | protected $linkDb; | 30 | protected $linkDb; |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * @var \History | 33 | * @var \Shaarli\History |
34 | */ | 34 | */ |
35 | protected $history; | 35 | protected $history; |
36 | 36 | ||