storm icon indicating copy to clipboard operation
storm copied to clipboard

Make extend() method usable with behaviors.

Open mjauvin opened this issue 3 years ago • 5 comments

Replaces #112

Model::extend(function ($model) {
    $model->behaviorMethodAvailable();
}, after: true);

Related: https://github.com/wintercms/docs/pull/98

mjauvin avatar Sep 08 '22 04:09 mjauvin

@mjauvin I've tweaked the property names and did some clean up of the Extendable trait. Feel free to revert if you disagree with it all :)

bennothommo avatar Sep 08 '22 06:09 bennothommo

So, who's in favor of merging this? Or something similar but through a seperate dedicated method ( e.g. extendPostBehavior() )

mjauvin avatar Sep 11 '22 17:09 mjauvin

@mjauvin are you needing this in 1.2.1 or are you fine with waiting for 1.2.2?

LukeTowers avatar Sep 13 '22 15:09 LukeTowers

@LukeTowers I'm fine to wait for 1.2.2, which is why I moved it there.

mjauvin avatar Sep 13 '22 15:09 mjauvin

Should I create a PR to the docs repo documenting this?

mjauvin avatar Oct 07 '22 11:10 mjauvin

This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days. If this is still being worked on, please respond and we will re-open this pull request. If this pull request is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

github-actions[bot] avatar Dec 08 '22 01:12 github-actions[bot]

Just to note - this PR could be implemented via https://github.com/wintercms/storm/pull/134 instead if we wanted to go down that route.

@mjauvin's use case could be simply extending a particular instance of the model locally via $model->extend(), which happens after instantiation and so other methods created by behaviors or other extensions would already be available.

bennothommo avatar Dec 25 '22 12:12 bennothommo

Just to note - this PR could be implemented via #134 instead if we wanted to go down that route.

@mjauvin's use case could be simply extending a particular instance of the model locally via $model->extend(), which happens after instantiation and so other methods created by behaviors or other extensions would already be available.

@bennothommo are you saying I could do:

MyModel::extend(function () {
    $this->extend(function () {
        $this->behaviorMethodAvailable();
    });
}, true);

And that $this->behaviorMethodAvailbale() call would work?

mjauvin avatar Feb 18 '23 15:02 mjauvin

Close in favor of #134.

mjauvin avatar Feb 18 '23 15:02 mjauvin