Using PHP Attribute in CraftCMS.
Then tell Composer to load the library:
composer require panlatent/craft-attribute
For Web Controllers, you can inherit panlatent\craft\attribute\web\Controller
or use Trait panlatent\craft\attribute\web\HasAttributes
to use these attributes:
Attribute | Targets | Scopes |
---|---|---|
#[AllowAnonymous] | Controller | Class |
#[RequireLogin] | ControllerAction | Method |
#[RequirePostRequest] | ControllerAction | Method |
#[RequireAcceptsJson] | ControllerAction | Method |
The Element Messages is open-sourced software licensed under the MIT license.