From bde2fb548f5f5f5541f8ad80f50349a307efe76d Mon Sep 17 00:00:00 2001 From: Matt Gray Date: Thu, 12 May 2022 11:56:41 +0100 Subject: [PATCH 1/2] Craft 4 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3716983..8a08ca8 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "mattgrayisok/craft-recently-viewed", "description": "Craft CMS plugin to find recently viewed elements of any type.", "type": "craft-plugin", - "version": "1.0.3", + "version": "1.0.4", "keywords": [ "craft", "cms", @@ -23,7 +23,7 @@ } ], "require": { - "craftcms/cms": "^3.0.0-RC1" + "craftcms/cms": "^3.0.0-RC1|^4.0.0-beta.1" }, "autoload": { "psr-4": { From 285c366b892d6c172c1fd530ec80e979d5cfa164 Mon Sep 17 00:00:00 2001 From: Matt Gray Date: Thu, 12 May 2022 12:23:49 +0100 Subject: [PATCH 2/2] Updates for Craft 4 function declarations --- CHANGELOG.md | 14 ++++++++++++-- composer.json | 5 +++-- src/RecentlyViewed.php | 10 +++++----- src/models/Settings.php | 2 +- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9ac51b..0a34fa4 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,23 +1,33 @@ # Recently Viewed Changelog -All notable changes to this project will be documented in this file. +## 2.0.0 - 2022-05-12 -The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +### Added + +- Craft 4 compat ## 1.0.3 - 2019-01-10 + ### Added + - Postgres support - Max limit of 99 elements in history ## 1.0.2 - 2019-01-08 + ### Updated + - Fixed null state issue when combined with ordering ## 1.0.1 - 2019-01-07 + ### Updated + - Made filtering work nicely with `limit()`s - Set elements as most recently viewed even if they are already in list of elements ## 1.0.0 - 2019-01-07 + ### Added + - Initial release diff --git a/composer.json b/composer.json index 8a08ca8..1529906 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "mattgrayisok/craft-recently-viewed", "description": "Craft CMS plugin to find recently viewed elements of any type.", "type": "craft-plugin", - "version": "1.0.4", + "version": "2.0.0", "keywords": [ "craft", "cms", @@ -23,7 +23,8 @@ } ], "require": { - "craftcms/cms": "^3.0.0-RC1|^4.0.0-beta.1" + "craftcms/cms": "^4.0.0-beta.1", + "php": "^8.0.0" }, "autoload": { "psr-4": { diff --git a/src/RecentlyViewed.php b/src/RecentlyViewed.php index 8ee88ff..8b9de96 100755 --- a/src/RecentlyViewed.php +++ b/src/RecentlyViewed.php @@ -14,7 +14,7 @@ use mattgrayisok\recentlyviewed\behaviors\RecentlyViewedBehavior; use mattgrayisok\recentlyviewed\models\Settings; - +use craft\base\Model; use Craft; use craft\base\Plugin; use craft\services\Plugins; @@ -49,9 +49,9 @@ class RecentlyViewed extends Plugin /** * @var string */ - public $schemaVersion = '1.0.2'; + public string $schemaVersion = '1.0.2'; - public $hasCpSettings = true; + public bool $hasCpSettings = true; /** * @inheritdoc @@ -103,12 +103,12 @@ public function registerComponentsAndServices() }); } - protected function createSettingsModel() + protected function createSettingsModel() : ?Model { return new Settings(); } - protected function settingsHtml() + protected function settingsHtml() : ?string { return \Craft::$app->getView()->renderTemplate('recently-viewed/settings', [ 'settings' => $this->getSettings() diff --git a/src/models/Settings.php b/src/models/Settings.php index ebd3769..061f64a 100644 --- a/src/models/Settings.php +++ b/src/models/Settings.php @@ -8,7 +8,7 @@ class Settings extends Model { public $autoTrack = true; - public function rules() + public function rules(): array { return [ [['autoTrack'], 'boolean'],