X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FHistory.php;h=bd5c1bf7318b63cec18905f99075b5c3a89c3a40;hb=47d15818502b11315b484131aaf67a3e3f441c5a;hp=5e3b1b72d475ce97fd05692bec751e661b13e182;hpb=66e74d50d38a6fea8fc904a1746157633de7cc65;p=github%2Fshaarli%2FShaarli.git diff --git a/application/History.php b/application/History.php index 5e3b1b72..bd5c1bf7 100644 --- a/application/History.php +++ b/application/History.php @@ -1,4 +1,10 @@ addEvent(self::CREATED, $link['id']); + $this->addEvent(self::CREATED, $link->getId()); } /** * Add Event: update existing link. * - * @param array $link Link data. + * @param Bookmark $link Link data. */ public function updateLink($link) { - $this->addEvent(self::UPDATED, $link['id']); + $this->addEvent(self::UPDATED, $link->getId()); } /** * Add Event: delete existing link. * - * @param array $link Link data. + * @param Bookmark $link Link data. */ public function deleteLink($link) { - $this->addEvent(self::DELETED, $link['id']); + $this->addEvent(self::DELETED, $link->getId()); } /** @@ -130,7 +136,7 @@ class History /** * Add Event: bulk import. * - * Note: we don't store links add/update one by one since it can have a huge impact on performances. + * Note: we don't store bookmarks add/update one by one since it can have a huge impact on performances. */ public function importLinks() { @@ -166,12 +172,12 @@ class History */ protected function check() { - if (! is_file($this->historyFilePath)) { + if (!is_file($this->historyFilePath)) { FileUtils::writeFlatDB($this->historyFilePath, []); } - if (! is_writable($this->historyFilePath)) { - throw new Exception('History file isn\'t readable or writable'); + if (!is_writable($this->historyFilePath)) { + throw new Exception(t('History file isn\'t readable or writable')); } } @@ -182,7 +188,7 @@ class History { $this->history = FileUtils::readFlatDB($this->historyFilePath, []); if ($this->history === false) { - throw new Exception('Could not parse history file'); + throw new Exception(t('Could not parse history file')); } } @@ -191,7 +197,7 @@ class History */ protected function write() { - $comparaison = new DateTime('-'. $this->retentionTime . ' seconds'); + $comparaison = new DateTime('-' . $this->retentionTime . ' seconds'); foreach ($this->history as $key => $value) { if ($value['datetime'] < $comparaison) { unset($this->history[$key]);