diff options
| author | 2023-12-15 23:04:29 +0100 | |
|---|---|---|
| committer | 2023-12-15 23:04:29 +0100 | |
| commit | 6bb45a87268157aab961a6a4a728d9a9bbe043b0 (patch) | |
| tree | d1c36638d5ee61e2e663d214d724a71f07a89354 /app/Models/Category.php | |
| parent | a3ed8269132303eebc03d3e6df822f1f101fa95b (diff) | |
Add filter actions (auto mark read) at category and global levels (#5942)
* Add filter actions (auto mark read) at category level
fix https://github.com/FreshRSS/FreshRSS/issues/3497
* Add filter actions (auto mark read) at global level
fix https://github.com/FreshRSS/FreshRSS/issues/2788
* Fix feed category ID
* Minor comment
Diffstat (limited to 'app/Models/Category.php')
| -rw-r--r-- | app/Models/Category.php | 35 |
1 files changed, 4 insertions, 31 deletions
diff --git a/app/Models/Category.php b/app/Models/Category.php index ab08a5b74..b1e35650a 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -2,6 +2,7 @@ declare(strict_types=1); class FreshRSS_Category extends Minz_Model { + use FreshRSS_AttributesTrait, FreshRSS_FilterActionsTrait; /** * Normal @@ -22,21 +23,21 @@ class FreshRSS_Category extends Minz_Model { private ?array $feeds = null; /** @var bool|int */ private $hasFeedsWithError = false; - /** @var array<string,mixed> */ - private array $attributes = []; private int $lastUpdate = 0; private bool $error = false; /** * @param array<FreshRSS_Feed>|null $feeds */ - public function __construct(string $name = '', ?array $feeds = null) { + public function __construct(string $name = '', int $id = 0, ?array $feeds = null) { + $this->_id($id); $this->_name($name); if ($feeds !== null) { $this->_feeds($feeds); $this->nbFeeds = 0; $this->nbNotRead = 0; foreach ($feeds as $feed) { + $feed->_category($this); $this->nbFeeds++; $this->nbNotRead += $feed->nbNotRead(); $this->hasFeedsWithError |= $feed->inError(); @@ -120,18 +121,6 @@ class FreshRSS_Category extends Minz_Model { return (bool)($this->hasFeedsWithError); } - /** - * @phpstan-return ($key is non-empty-string ? mixed : array<string,mixed>) - * @return array<string,mixed>|mixed|null - */ - public function attributes(string $key = '') { - if ($key === '') { - return $this->attributes; - } else { - return $this->attributes[$key] ?? null; - } - } - public function _id(int $id): void { $this->id = $id; if ($id === FreshRSS_CategoryDAO::DEFAULTCATEGORYID) { @@ -169,22 +158,6 @@ class FreshRSS_Category extends Minz_Model { $this->sortFeeds(); } - /** @param string|array<mixed>|bool|int|null $value Value, not HTML-encoded */ - public function _attributes(string $key, $value): void { - if ('' === $key) { - if (is_string($value)) { - $value = json_decode($value, true); - } - if (is_array($value)) { - $this->attributes = $value; - } - } elseif (null === $value) { - unset($this->attributes[$key]); - } else { - $this->attributes[$key] = $value; - } - } - /** * @param array<string> $attributes * @throws FreshRSS_Context_Exception |
