Skip to content

Commit

Permalink
Craft 5 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Sep 29, 2024
1 parent d9b10fa commit 4c7d18a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 42 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 3.0.0 - 2024-09-29

### Changed
- Now requires Craft 5.0+.

## 2.0.0 - 2024-09-29
> {note} The plugin’s package name has changed to `verbb/readability`. Readability will need be updated to 2.0 from a terminal, by running `composer require verbb/readability && composer remove mikestecker/craft-readability`.
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "verbb/readability",
"description": "A set of Twig filters for showing statistics on your text.",
"type": "craft-plugin",
"version": "2.0.0",
"version": "3.0.0",
"keywords": [
"craft",
"cms",
Expand All @@ -29,10 +29,10 @@
}
],
"require": {
"php": "^8.0.2",
"craftcms/cms": "^4.0.0",
"php": "^8.2",
"craftcms/cms": "^5.0.0",
"davechild/textstatistics": "^1.0",
"verbb/base": "^2.0.0"
"verbb/base": "^3.0.0"
},
"autoload": {
"psr-4": {
Expand All @@ -42,7 +42,7 @@
"extra": {
"name": "Readability",
"handle": "readability",
"changelogUrl": "https://raw.githubusercontent.com/verbb/readability/craft-4/CHANGELOG.md",
"changelogUrl": "https://raw.githubusercontent.com/verbb/readability/craft-5/CHANGELOG.md",
"class": "verbb\\readability\\Readability"
}
}
2 changes: 0 additions & 2 deletions src/Readability.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public function init(): void

self::$plugin = $this;

$this->_setPluginComponents();
$this->_setLogging();
$this->_registerTwigExtensions();
}

Expand Down
50 changes: 15 additions & 35 deletions src/base/PluginTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,35 @@

use Craft;

use yii\log\Logger;

use verbb\base\BaseHelper;
use verbb\base\LogTrait;
use verbb\base\helpers\Plugin;

trait PluginTrait
{
// Static Properties
// =========================================================================

public static Readability $plugin;
public static ?Readability $plugin = null;


// Public Methods
// Traits
// =========================================================================

public static function log(string $message, array $attributes = []): void
{
if ($attributes) {
$message = Craft::t('readability', $message, $attributes);
}
use LogTrait;

Craft::getLogger()->log($message, Logger::LEVEL_INFO, 'readability');
}

public static function error(string $message, array $attributes = []): void
// Static Methods
// =========================================================================

public static function config(): array
{
if ($attributes) {
$message = Craft::t('readability', $message, $attributes);
}
Plugin::bootstrapPlugin('readability');

Craft::getLogger()->log($message, Logger::LEVEL_ERROR, 'readability');
return [
'components' => [
'service' => Service::class,
],
];
}


Expand All @@ -48,22 +46,4 @@ public function getService(): Service
return $this->get('service');
}


// Private Methods
// =========================================================================

private function _setPluginComponents(): void
{
$this->setComponents([
'service' => Service::class,
]);

BaseHelper::registerModule();
}

private function _setLogging(): void
{
BaseHelper::setFileLogging('readability');
}

}

0 comments on commit 4c7d18a

Please sign in to comment.