These solutions really break the 80/20 rule. Any way to just add a flag/enabling method to the router/front controller to do this and leave this stuff built-in?

K
----- Original Message ----- From: "Ralf Eggert" <[EMAIL PROTECTED]>
To: "Zend Framework General" <fw-general@lists.zend.com>
Sent: Thursday, December 21, 2006 10:33 AM
Subject: Re: [fw-general] noRouteAction ....no function ...please help


Hi,

I had the same problem a couple of weeks ago. Please have a look into
this discussion.

http://www.nabble.com/Default-controller-is-not-set-tf2746286s16154.html

Anyway, I created a plugin which simulates the old behavior. You
probably need to reformat the piece of code.

 class Plugin_Notfound extends Zend_Controller_Plugin_Abstract
 {
     public function preDispatch($request)
     {
         $dispatcher = Zend_Controller_Front::getInstance()
                       ->getDispatcher();

         if (!$dispatcher->isDispatchable($request))
         {

$request->setControllerName($dispatcher->getDefaultController())
                     ->setActionName('noroute')
                     ->setDispatched(false);
         }
     }
 }

Another solution is to handle the thrown exceptions in a custom
Zend_Controller_Response object by overwriting the __toString() method.

And finally you could create your own router to handle this (code copied
from Matthews mail):

   class My_Controller_Router extends Zend_Controller_Router
   {
       public function route($request)
       {
           parent::route($request);

           $dispatcher =
Zend_Controller_Front::getInstance()->getDispatcher();
           if (!$dispatcher->isDispatchable($request))
           {

$request->setControllerName($dispatcher->getDefaultController())
                       ->setActionName($dispatcher->getDefaultAction());
           }
       }
   }

Hth!

Best Regards,

Ralf




Reply via email to