devdocs icon indicating copy to clipboard operation
devdocs copied to clipboard

Scopes in which plugins can be used.

Open JamesAnelay opened this issue 11 years ago • 3 comments

So reading the docs on plugins it says "Limitations: You cannot use plug-ins for: Non-public methods". However in my testing I was able to create a Plugin for a protected method without an issue, should this read private methods?

JamesAnelay avatar Mar 27 '15 23:03 JamesAnelay

@bluk Can you answer? Thanks

ghost avatar Mar 30 '15 17:03 ghost

@JamesAnelay Can you share what protected method you wrote the plugin for? On the latest code, I don't think you can use plugins around protected methods. I tried it out with a couple around/after just to see as well and the Interceptor didn't generate the intercepting method, so I'm not sure how it worked for you.

Personally, I would strongly discourage writing a plugin around a protected method and would instead try to find a suitable public method. From a pure internals safety and stability standpoint, plugins are more suitable for public methods.

bluk avatar Mar 30 '15 19:03 bluk

Ok, I now see what was going wrong, so this was on my own code and as I was developing and testing a plugin on.

I thought "Does this need to be public to use a plugin on", changed it to protected and it still worked and there was the reason why because the Interceptor class had already been generated so changing the scope had no effect.

Thanks for clearing that up for me @bluk!

JamesAnelay avatar Mar 30 '15 20:03 JamesAnelay