Monday, January 31, 2011

Re: SecondController extends FirstController extends AppController: not supported? --psybear

Yeah, if you want to have an indeterminate depth of nested controllers
(which is fine), and you want to use Cake's component merging stuff,
then as far as I can tell you'll have to implement your own version of
Controller::__mergeVars() in your AppController class.

- Jamie

On Jan 31, 6:24 am, psybear83 <psybea...@gmail.com> wrote:
> Hey everybody
>
> I'm refactoring an application with some controllers and wanted to
> "divide" them into a group X (that needs some components) and a group
> Y that needs some other components. My idea:
>
> class AppController {
>   var $components = array('Html', 'Form');
>
> }
>
> class XController extends AppController {
>   var $components = array('X1', 'X2');
>
> }
>
> class YController extends AppController {
>   var $components = array('Y1', 'Y2');
>
> }
>
> Now every other controller should inherit from XController or from
> YController like this:
>
> class SomeXController extends XController {
>   var $components = array('Bla');
>
> }
>
> I expected XController now to have loaded the following components:
> Html, Form, X1, X2, and Bla. But sadly it doesn't have all of them! It
> seems CakePHP doesn't allow controller inheritance over more than only
> 1 level. Is this true? Is there any known work-around?
>
> Thanks a lot for help
> Josh

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: