Imitating Multiple Inheritance in PHP
Posted
by fabieno
on Stack Overflow
See other posts from Stack Overflow
or by fabieno
Published on 2010-05-03T11:48:52Z
Indexed on
2010/05/03
11:58 UTC
Read the original article
Hit count: 190
I am working on my own MVC framework and found myself stuck. I need the following construction:
Controller
--> Backend_Controller
--> Backend_Crud_Controller
--> Frontend_Controller
--> Frontend_Crud_Controller
Both 'Backend_Crud_Controller' and 'Frontend_Crud_Controller' have the same functionality and thus they should extend another class named 'Base_Crud_Controller', the only difference comes from the 'Backend/Frontend' Controllers which implement different mechanisms.
Basically they should inherit both classes but my problem is that 'Backend/Frontend' controller doesn't necessarily extend 'Base_Crud_Controller'.
I know multiple inheritance doesn't exist in PHP but I am looking for a solution, I choose to refrain Mixins (like in Symfony) as I don't consider that an elegant solution.
Interfaces do not suit me as all of these end up as concrete classes that should implement methods.
© Stack Overflow or respective owner