Results 1 to 5 of 5

Thread: Module controllers extending default controllers

  1. #1
    ECHK is offline Junior Member
    Join Date
    Jun 2009
    Posts
    3

    Default Module controllers extending default controllers

    Hi,

    I'm trying to set up a project as outlined in the zend framework documentation here: Zend Framework: Documentation

    Code:
    application/
        default/
            controllers/
                IndexController.php
                FooController.php
            models/
            views/
                scripts/
                    index/
                    foo/
                helpers/
                filters/
        blog/
            controllers/
                IndexController.php
                FooController.php
            models/
            views/
                scripts/
                    index/
                helpers/
                filters/
    My problem is that, my Blog_Controller_FooController class extends the default FooController.

    default/controllers/FooController.php:
    Code:
    Class FooController extends Default_Controller_Base
    { ...
    }
    blog/controllers/FooController.php:
    Code:
    require_once(APPLICATION_PATH . '/default/controllers/FooController.php');
    Class Blog_FooController extends FooController
    { ...
    }
    I need to put require_once or else the application cannot find class FooController. I can't change the class name FooController to Default_Controller_FooController either, as it would not recognize when I try to call its methods.
    Is there any other way I can solve this without using require_once? I'd sincerely appreciate if you could offer any suggestion.

    Thanks,
    EC

  2. #2
    Tekerson is offline Senior Member
    Join Date
    Jul 2008
    Posts
    288

    Default

    Short answer is not really, other than messing with the autoloader.

    I'd ask what you are using the base controller for though? Everything I've encountered so far that you would want to do in a base controller can be done in action helpers or plugins.
    Brenton Alker
    PHP Developer - Brisbane, Australia

    blog.tekerson.com | twitter.com/tekerson | brenton.mp

  3. #3
    ECHK is offline Junior Member
    Join Date
    Jun 2009
    Posts
    3

    Default

    I've been trying to mess with my autoloader but haven't been able to find a way, so if you have any good idea on how to do it I'd love to hear. Thanks in advance!

    The base controller is used for handling operations common for other default controllers.

  4. #4
    alokin is offline Senior Member
    Join Date
    Apr 2009
    Posts
    211

    Default

    Quote Originally Posted by ECHK View Post
    The base controller is used for handling operations common for other default controllers.
    Read this article: Action Helpers in Zend Framework

  5. #5
    ECHK is offline Junior Member
    Join Date
    Jun 2009
    Posts
    3

    Default

    Thank you very much for replying. Yes the Default_Controller_Base can be substitute with action helper, however, default class FooController (default/controller/FooController.php) itself is a controller of its own. And Blog_Controller_FooController.php _needs_ to extend from it. It is the design requirement.

    Any other suggestions?

Similar Threads

  1. URL Paths in Controllers
    By jwburnside in forum Model-View-Controller (MVC)
    Replies: 1
    Last Post: 10-18-2010, 05:44 PM
  2. Request to invalid module handled by default module?
    By papayasoft in forum Model-View-Controller (MVC)
    Replies: 2
    Last Post: 04-13-2010, 04:29 AM
  3. Controllers
    By santhosh in forum Model-View-Controller (MVC)
    Replies: 1
    Last Post: 10-14-2009, 10:24 AM
  4. Zend Framework - Extending Controllers
    By searbe in forum General Q&A on Zend Framework
    Replies: 0
    Last Post: 10-04-2009, 09:36 PM
  5. Replies: 4
    Last Post: 10-02-2009, 03:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •