Skip to content

Commit

Permalink
feat: Initial Craft CMS 4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Feb 23, 2022
1 parent 013c5d8 commit 861206b
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 178 deletions.
49 changes: 38 additions & 11 deletions src/Typogrify.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@

namespace nystudio107\typogrify;

use nystudio107\typogrify\services\TypogrifyService;
use nystudio107\typogrify\twigextensions\TypogrifyTwigExtension;
use nystudio107\typogrify\models\Settings;
use nystudio107\typogrify\variables\TypogrifyVariable;

use Craft;
use craft\base\Model;
use craft\base\Plugin;
use craft\web\twig\variables\CraftVariable;

use nystudio107\typogrify\models\Settings;
use nystudio107\typogrify\services\TypogrifyService;
use nystudio107\typogrify\twigextensions\TypogrifyTwigExtension;
use nystudio107\typogrify\variables\TypogrifyVariable;
use yii\base\Event;

/**
Expand All @@ -28,9 +27,8 @@
* @package Typogrify
* @since 1.0.0
*
* @property Settings $settings
* @property Settings $settings
* @property TypogrifyService $typogrify
* @method Settings getSettings()
*/
class Typogrify extends Plugin
{
Expand All @@ -47,13 +45,42 @@ class Typogrify extends Plugin
*/
public static $variable;

// Public Properties
// =========================================================================

/**
* @var string
*/
public string $schemaVersion = '1.0.0';

/**
* @var bool
*/
public bool $hasCpSettings = false;
/**
* @var bool
*/
public bool $hasCpSection = false;

/**
* @inheritdoc
*/
public function __construct($id, $parent = null, array $config = [])
{
$config['components'] = [
'typogrify' => TypogrifyService::class,
];

parent::__construct($id, $parent, $config);
}

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

/**
* @inheritdoc
*/
public function init()
public function init(): void
{
parent::init();
self::$plugin = $this;
Expand All @@ -64,7 +91,7 @@ public function init()
Event::on(
CraftVariable::class,
CraftVariable::EVENT_INIT,
function (Event $event) {
static function (Event $event) {
/** @var CraftVariable $variable */
$variable = $event->sender;
$variable->set('typogrify', self::$variable);
Expand All @@ -87,7 +114,7 @@ function (Event $event) {
/**
* @inheritdoc
*/
protected function createSettingsModel()
protected function createSettingsModel(): ?Model
{
return new Settings();
}
Expand Down
Loading

0 comments on commit 861206b

Please sign in to comment.