-- Pieter <[EMAIL PROTECTED]> wrote
(on Thursday, 31 January 2008, 09:52 PM +0100):
> It seems that the dispatcher is naming it to ShoppingcartController or 
> similiar, but that the viewRenderer takes the controller name like called. 
> But I am not sure that it is a bug, because it is also possible that the 
> dispatcher renames it to SHOPPINGCARTController, and I know that the 
> viewRenderer is turning camelized names into a small letter with a dash.

You've hit the nail on the head. 

First off, class names are case insensitive; as long as the class is
already loaded, you can refer to it using any mixture of case:

    $controller = new ShoppingCartController();
    $controller = new SHOPPINGCARTController();
    $controller = new shoppingcartController();

(Don't believe me? try it!)

Additionally, the dispatcher does some normalization of the name. In
this case, each '-' indicates a word space, and the dispatcher
CamelCasesWords, so in the end, it will instantiate the
SHOPPINGCARTController class (since each letter is separated with a word
spacer).

The ViewRenderer does similarly, but actually looks for names that mimic
what's on the URL. This is partly to make debugging your view scripts
easier: you already know the URL where the issue occurs, so now you can
look at your view scripts directory and find the matching filename. The
other is simply normalization - this way we don't have to worry about
case sensitivity in the file system.


> mezoni schreef:
>> I have a controller named 'ShoppingCartController'.
>> When I reaquest this action like this 
>> http://mysite/s-h-o-p-p-i-n-g-c-a-r-t
>> I get the following error:
>> Uncaught exception 'Zend_View_Exception' with message
>> 'script 's-h-o-p-p-i-n-g-c-a-r-t/index.phtml' not found in path
>> (.\application\modules\default\views\scripts\)'
>> in Y:\home\test1.ru\www\library\Zend\View\Abstract.php:853
>>
>> Why?
>>
>> I'm not have the 'S-h-o-p-p-i-n-g-c-a-r-tController'...
>>
>> Why I not get the following error?
>> Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message
>> 'Invalid controller specified (s-h-o-p-p-i-n-g-c-a-r-t)'
>> in 
>> Y:\home\test1.ru\www\library\Zend\Controller\Dispatcher\Standard.php:198
>>
>> I'm sorry for my English...
>>   
>
>

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to