Jump to content

Make public methods of component controllers available in controller views like it is in regular controllers and views


Ivan Gretsky
 Share

Recommended Posts

Good day, @teppo!

Hope you're doing fine. I am using Wireframe in everything I build now) And devs I collaborate with love it as it gives us a defined common ground. Thanks!

We are using components a lot. Particularly for RM based content builder. And we often need to call some component-unique logic from the component view. I wish we could do it like we can in regular views: just calling a public method of component controller as a function (or a property). It doesn't seem to be a feature now. Could this be added?

  • Like 1
Link to comment
Share on other sites

Good day, Ivan. Glad to hear that you're enjoying Wireframe ?

41 minutes ago, Ivan Gretsky said:

And we often need to call some component-unique logic from the component view. I wish we could do it like we can in regular views: just calling a public method of component controller as a function (or a property). It doesn't seem to be a feature now. Could this be added?

Could you clarify how you're calling such methods in case of regular views?

You should be already able to access component class methods from a component view with $this->method_name, similar to they way you access controller class methods from regular views. Both Controller and Component base classes implement MethodPropsTrait, which enables this behaviour.

But if you're looking for something along the lines of View::getController(), ComponentView didn't have a direct method for that. Pretty sure this was originally by design (to keep component views from becoming too complex), but I've added a similar method in latest version (0.26.0) just in case: ComponentView::getComponent().

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...