Skip to content

Commit

Permalink
Craft 4 Support (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
khamer authored Aug 22, 2022
1 parent cdf5e08 commit 76df9b5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
}
],
"require": {
"craftcms/cms": "^3.0.0-beta.20"
"php": "^8.0",
"craftcms/cms": "^3.0.0-beta.20 || ^4.0.0"
},
"autoload": {
"psr-4": {
Expand All @@ -34,5 +35,10 @@
"handle": "code-mirror",
"changelogUrl": "https://raw.githubusercontent.com/luwes/craft3-codemirror/master/CHANGELOG.md",
"class": "luwes\\codemirror\\CodeMirror"
},
"minimum-stability": "dev",
"prefer-stable": true,
"require-dev": {
"craftcms/rector": "dev-main"
}
}
2 changes: 1 addition & 1 deletion src/CodeMirror.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function (PluginEvent $event) {
// Protected Methods
// =========================================================================

protected function createSettingsModel()
protected function createSettingsModel(): ?\craft\base\Model
{
return new Settings();
}
Expand Down
12 changes: 6 additions & 6 deletions src/fields/CodeMirrorField.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function displayName(): string
/**
* @inheritdoc
*/
public function rules()
public function rules(): array
{
$rules = parent::rules();
$rules = array_merge($rules, [
Expand All @@ -63,31 +63,31 @@ public function rules()
/**
* @inheritdoc
*/
public function getContentColumnType(): string
public function getContentColumnType(): array|string
{
return Schema::TYPE_TEXT;
}

/**
* @inheritdoc
*/
public function normalizeValue($value, ElementInterface $element = null)
public function normalizeValue(mixed $value, ?\craft\base\ElementInterface $element = null): mixed
{
return $value;
}

/**
* @inheritdoc
*/
public function serializeValue($value, ElementInterface $element = null)
public function serializeValue(mixed $value, ?\craft\base\ElementInterface $element = null): mixed
{
return parent::serializeValue($value, $element);
}

/**
* @inheritdoc
*/
public function getSettingsHtml()
public function getSettingsHtml(): ?string
{
$settings = CodeMirror::getInstance()->getSettings();
$modes = [];
Expand All @@ -114,7 +114,7 @@ public function getSettingsHtml()
/**
* @inheritdoc
*/
public function getInputHtml($value, ElementInterface $element = null): string
public function getInputHtml(mixed $value, ?\craft\base\ElementInterface $element = null): string
{
$am = Craft::$app->getAssetManager();
$view = Craft::$app->getView();
Expand Down

0 comments on commit 76df9b5

Please sign in to comment.