Skip to content

Instantly share code, notes, and snippets.

@bencroker
Last active February 28, 2022 10:25
Show Gist options
  • Save bencroker/3cfe009861dc3c77f1eb44c84482d5c3 to your computer and use it in GitHub Desktop.
Save bencroker/3cfe009861dc3c77f1eb44c84482d5c3 to your computer and use it in GitHub Desktop.
Craft 4 Plugin Changes

Craft 4 Plugin Changes

Composer Requirements

Before

"require": {
   "craftcms/cms": "^3.0.0"
},

After

"require": {
   "craftcms/cms": "^4.0.0-alpha"
},

Method Return Types

Before

public method init()

After

public method init(): void

Registering User Permissions

Before

$event->permissions['Blitz'] = [
   'blitz:clear' => [
       'label' => Craft::t('blitz', 'Clear cache')
   ],
];

After

$event->permissions[] = [
   'heading' => 'Blitz',
   'permissions' => [
       'blitz:clear' => [
           'label' => Craft::t('blitz', 'Clear cache')
       ],
   ],
];

Editable Table Fields

Before

{{ forms.editableTableField({
   label: "Included URI Patterns"|t('blitz'),
   name: 'settings[includedUriPatterns]',
   id: 'includedUriPatterns',
   cols: cols,
   rows: settings.includedUriPatterns,
   addRowLabel: "Add a URI pattern"|t('blitz'),
}) }}

After

{{ forms.editableTableField({
    label: "Included URI Patterns"|t('blitz'),
    name: 'settings[includedUriPatterns]',
    id: 'includedUriPatterns',
    cols: cols,
    rows: settings.includedUriPatterns,
    addRowLabel: "Add a URI pattern"|t('blitz'),
    allowAdd: true,
    allowDelete: true,
    allowReorder: true,
}) }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment