Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Hook::on in Block with enabled cache #146

Open
TheMaaarc opened this issue Oct 11, 2018 · 6 comments
Open

Hook::on in Block with enabled cache #146

TheMaaarc opened this issue Oct 11, 2018 · 6 comments

Comments

@TheMaaarc
Copy link
Member

If you use the Hook::on function in a block with cache enabled it only works once (after cache clear).

Currently I invoke the function in the view file, is there a possibility to exclude certain functions in the block from caching?

@nadar nadar self-assigned this Oct 11, 2018
@nadar
Copy link
Member

nadar commented Oct 11, 2018

Maybe we can have an event listener which is triggered accordingly (whether its register from cache or not):

$this->on(self::EVENT_AFTER_REGISTER, function() {
// do your stuff
});

@nadar
Copy link
Member

nadar commented Feb 27, 2019

@boehsermoe onRegister() and onRegisterFromCache() should trigger an event which blocks can register listeneres while initialize (init() method) (example above)

@boehsermoe
Copy link
Member

Ok I will take a closer look at the next days.

@nadar
Copy link
Member

nadar commented Mar 1, 2019

i think $this->trigger(self::EVENT_ON_REGISTER) should do the job, maybe i will find time next week.

@boehsermoe
Copy link
Member

I think it is a little more difficult. For one the block classes does not have any event handling implemented yet. The other thing is if you override a view from a core block (or other module) you cannot listen on this event without make your own block. It should be able to listen on events via block variants too. What do you think?

@nadar
Copy link
Member

nadar commented Mar 5, 2019

The event handling can be achieved by using Component instead of BaseObject for InternalBaseBlock. I think this is just a more wide used behavior when registering hooks (or other things) inside a block, therefore this event is used.

@nadar nadar removed their assignment Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants