Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Content]: Manually attaching behaviors #602

Open
AugustMiller opened this issue Apr 19, 2024 · 0 comments
Open

[Content]: Manually attaching behaviors #602

AugustMiller opened this issue Apr 19, 2024 · 0 comments

Comments

@AugustMiller
Copy link
Contributor

Product

Craft CMS

Description

In a conversation about modifying built-in services, @bencroker noted that we don't mention yii\base\Component::attachBehavior() as an alternative to the event-based approach.

Most classes in Craft ultimately inherit from this (including our core services), so it's possible to augment them without going via an intermediate event listener:

Craft::$app->getGc()->attachBehavior('myPlugin.garbageEnhancements', TurboTrash::class);

This bears some similarities to our discussion of instance-level events.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant