1

Is it possible to call a method of a plugin's controller from within a plugin? I don't plan on making a habit of this but sometimes it may be needed. Just trying to plan ahead.

Thanks!

  • 1
    Wouldn't it make more sense to just off-load that logic into a service, and simply make the service accessible instead? – Lindsey D Mar 24 '15 at 6:14
4

Something like this should work:

`craft()->runController('pluginHandle/controllerId/action');`

Although I'd question the decisions you've made to get to the point where you had to ask this question. ;)

|improve this answer|||||
  • Thanks. I haven't needed to do this yet and yes of course I want to avoid it. What I'm thinking is if I have a controller that does a thing, and I have zero time to refactor that process into a service, then I might as well just call the controller. – Matt V Mar 24 '15 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.