Monday, July 27, 2015

Re: CakePHP 3.0 Plugin - Where to put a « global » function for multiple helpers

I cannot do that without multiple inheritance (which, as far as I know, does not exist in php) because as I stated in my post, all my helpers does not inherit a standard CakePHP helpers, for instance I have:

class MyHTMLHelper extends HTMLHelper { ... }
class MyFormHelper extends FormHelper { ... }
class MyPagiHelper extends PaginatorHelper { ... }

On Monday, July 27, 2015 at 11:28:00 AM UTC+2, Florian Krämer wrote:
Simple OOP?

MySpecialHelper extends MyBaseHelper {...}
MyOtherSpecialHelper extends MyBaseHelper {...}



And MyBaseHelper implementds addClass().

On Friday, July 24, 2015 at 10:23:43 AM UTC+2, Mikaël Capelle wrote:
Hi everyone,

I am writing a CakePHP 3.0 plugins, and I have multiple helpers (inheriting from either HTMLHelper, FormHelper, PaginatorHelper, etc.). In each of these new helpers, I have a function addClass (copy/paste from helper to helper... ).

I don't really like having duplicated code (5 times... ), but I don't know where I should put this function to follow CakePHP 3.0 plugin conventions, knowing that the plugin consists of only helpers?

Thanks.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: