From 6bb45a87268157aab961a6a4a728d9a9bbe043b0 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 15 Dec 2023 23:04:29 +0100 Subject: 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 --- app/Models/AttributesTrait.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/Models/AttributesTrait.php (limited to 'app/Models/AttributesTrait.php') diff --git a/app/Models/AttributesTrait.php b/app/Models/AttributesTrait.php new file mode 100644 index 000000000..39154182b --- /dev/null +++ b/app/Models/AttributesTrait.php @@ -0,0 +1,40 @@ + + */ + private array $attributes = []; + + /** + * @phpstan-return ($key is non-empty-string ? mixed : array) + * @return array|mixed|null + */ + public function attributes(string $key = '') { + if ($key === '') { + return $this->attributes; + } else { + return $this->attributes[$key] ?? null; + } + } + + /** @param string|array|bool|int|null $value Value, not HTML-encoded */ + public function _attributes(string $key, $value = null): void { + if ($key == '') { + if (is_string($value)) { + $value = json_decode($value, true); + } + if (is_array($value)) { + $this->attributes = $value; + } + } elseif ($value === null) { + unset($this->attributes[$key]); + } else { + $this->attributes[$key] = $value; + } + } +} -- cgit v1.2.3