Skip to content

Commit 0b2c199

Browse files
committed
Update for Craft 5
1 parent 4890f05 commit 0b2c199

3 files changed

Lines changed: 45 additions & 43 deletions

File tree

composer.json

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
{
2-
"name": "ether/notes",
3-
"description": "A note taking field type for Craft CMS 3",
4-
"version": "1.0.6",
5-
"type": "craft-plugin",
6-
"license": "proprietary",
7-
"minimum-stability": "dev",
8-
"require": {
9-
"craftcms/cms": "^3.5"
10-
},
11-
"autoload": {
12-
"psr-4": {
13-
"ether\\notes\\": "src/"
14-
}
15-
},
16-
"support": {
17-
"email": "help@ethercreative.co.uk",
18-
"source": "https://github.com/ethercreative/notes",
19-
"issues": "https://github.com/ethercreative/notes/issues"
20-
},
21-
"extra": {
22-
"handle": "notes",
23-
"name": "Notes",
24-
"developer": "Ether Creative",
25-
"developerUrl": "https://ethercreative.co.uk",
26-
27-
"class": "ether\\notes\\Notes",
28-
"schemaVersion": "1.0.0"
29-
}
2+
"name": "ether/notes",
3+
"description": "A note taking field type for Craft CMS 3",
4+
"type": "craft-plugin",
5+
"license": "proprietary",
6+
"minimum-stability": "dev",
7+
"require": {
8+
"craftcms/cms": "^5",
9+
"php": "^8.0"
10+
},
11+
"autoload": {
12+
"psr-4": {
13+
"ether\\notes\\": "src/"
14+
}
15+
},
16+
"support": {
17+
"email": "help@ethercreative.co.uk",
18+
"source": "https://github.com/ethercreative/notes",
19+
"issues": "https://github.com/ethercreative/notes/issues"
20+
},
21+
"extra": {
22+
"handle": "notes",
23+
"name": "Notes",
24+
"developer": "Ether Creative",
25+
"developerUrl": "https://ethercreative.co.uk",
26+
"class": "ether\\notes\\Notes",
27+
"schemaVersion": "1.0.0"
28+
}
3029
}

src/Field.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static function supportedTranslationMethods (): array
5555
];
5656
}
5757

58-
public function normalizeValue ($value, ElementInterface $element = null)
58+
public function normalizeValue ($value, ElementInterface $element = null): mixed
5959
{
6060
if (!$element)
6161
return [];
@@ -66,7 +66,7 @@ public function normalizeValue ($value, ElementInterface $element = null)
6666
);
6767
}
6868

69-
public function getSettingsHtml ()
69+
public function getSettingsHtml (): ?string
7070
{
7171
// 1.0.2 back-compat
7272
$allowDeleting = $this->allowDeleting;
@@ -81,7 +81,7 @@ public function getSettingsHtml ()
8181
]);
8282
}
8383

84-
protected function inputHtml ($value, ElementInterface $element = null): string
84+
protected function inputHtml ($value, ?ElementInterface $element, bool $inline): string
8585
{
8686
if (!$element || !$element->id)
8787
return Craft::t('notes', 'You must save the element before you can add notes!');

src/Notes.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
class Notes extends Plugin
2727
{
2828

29-
public function init ()
29+
public function init(): void
3030
{
3131
parent::init();
3232

@@ -47,22 +47,25 @@ public function init ()
4747
);
4848
}
4949

50-
public function onRegisterFieldTypes (RegisterComponentTypesEvent $event)
50+
public function onRegisterFieldTypes(RegisterComponentTypesEvent $event): void
5151
{
5252
$event->types[] = Field::class;
5353
}
5454

55-
public function onRegisterPermissions (RegisterUserPermissionsEvent $event)
55+
public function onRegisterPermissions(RegisterUserPermissionsEvent $event): void
5656
{
57-
$event->permissions['Notes'] = [
58-
'addNotes' => [
59-
'label' => Craft::t('notes', 'Add notes'),
60-
],
61-
'deleteOwnNotes' => [
62-
'label' => Craft::t('notes', 'Delete own notes'),
63-
],
64-
'deleteAllNotes' => [
65-
'label' => Craft::t('notes', 'Delete all notes'),
57+
$event->permissions['notes'] = [
58+
'heading' => 'Notes',
59+
'permissions' => [
60+
'addNotes' => [
61+
'label' => Craft::t('notes', 'Add notes'),
62+
],
63+
'deleteOwnNotes' => [
64+
'label' => Craft::t('notes', 'Delete own notes'),
65+
],
66+
'deleteAllNotes' => [
67+
'label' => Craft::t('notes', 'Delete all notes'),
68+
],
6669
],
6770
];
6871
}

0 commit comments

Comments
 (0)