View Single Post
  #15 (permalink)  
Old 08-29-2008, 04:38 PM
blinky001 blinky001 is offline
Junior Member
 
Join Date: Aug 2008
Location: Lancaster, UK
Posts: 2
Default Similar issues here...

I'm also pretty new to the Zend Framework and having no luck with the error controller either. I have a slightly different setup to the others, but nothing drastic. I have 3 'modules' defined - public (default), shared, and admin. Public uses the preDispatch method of the Zend_Controller_Plugin_Abstract:

[PHP]<?php

# Route all requests to the index controller / index action
class APP_Controller_Plugin_CleanUrls extends Zend_Controller_Plugin_Abstract
{

public function preDispatch(Zend_Controller_Request_Abstract $request)
{
if($request->module == 'public')
{
# This is the dynamic part of the site - route everything to the index controller
$request->setControllerName('index');
$request->setActionName('index');
}
else
{
echo 'using: '.$request->module.' module<br />';
}
}

}[/PHP]

and for now lets me know which module I am using if it is not the default (public) one. The index controller works as planned handling 404s / 500s etc itself without the error controller. However, I do want this enabled for the admin part of the site. The important part of my bootstrap file is as follows:

[PHP]# Get the front controller
$frontController = Zend_Controller_Front::getInstance();

$frontController->setControllerDirectory(array(
'public' => APP_DIR.'core'.DS.'public'.DS.'controllers',
'shared' => APP_DIR.'core'.DS.'shared'.DS.'controllers',
'admin' => APP_DIR.'core'.DS.'admin'.DS.'controllers'
));

$frontController->setDefaultModule('public');

$frontController->registerPlugin(new APP_Controller_Plugin_CleanUrls());[/PHP]

My admin IndexController file works fine, as does the admin ErrorController file if I reference it absolutely: http://local.zendTest/admin/error/error. However, if I try http://local.zendTest/admin/error/errorX or http://local.zendTest/admin/X I get the following:

[HTML]using: admin module
using: admin module
using: admin module

Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)'
in C:\Server\htdocs\cms\framework\Zend\Controller\Dis patcher\Standard.php:249

Stack trace:
#0 C:\Server\htdocs\cms\framework\Zend\Controller\Fro nt.php(914):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 C:\Server\htdocs\cms\sites\site1\public\index.php( 9):
Zend_Controller_Front->dispatch()
#2 {main} thrown in C:\Server\htdocs\cms\framework\Zend\Controller\Dis patcher\Standard.php on line 249[/HTML]

Not sure what I am doing wrong? My admin ErrorController looks like this (pretty much straight out of the manual) where APP_Controller_Action is my own override:

[PHP]<?php

class Admin_ErrorController extends APP_Controller_Action
{
public function errorAction()
{
$errors = $this->_getParam('error_handler');

if(is_object($errors))
{
switch($errors->type)
{
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ ACTION:

# 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = 'Page not found';
break;
default:
# application error
$this->getResponse()->setHttpResponseCode(500);
$this->view->message = 'Application error';
break;
}

$this->view->title = 'Errors';
$this->view->env = $this->getInvokeArg('env');
$this->view->exception = $errors->exception;
$this->view->request = $errors->request;
}
else
{
$this->view->title = 'No Errors';
$this->view->message = 'No Errors Detected';
}
}
}[/PHP]

Can anyone shed any light on this situation at all?

Thanks in advance,

Paul
Reply With Quote