View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

{zone-data:component-name}
Zend_Controller_Dispatcher
{zone-data}

{zone-data:proposer-list}
[zf@keppens.net|mailto:zf@keppens.net]
{zone-data}

{zone-data:revision}
{zone-data}

{zone-data:overview}
In smal projects the current directory structure for controllers is sufficient. For bigger projects however, it might be useful to use subdirectories to group together certain functonalities for clarity reasons.
{zone-data}

{zone-data:references}
{zone-data}

{zone-data:requirements}
* KISS
{zone-data}

{zone-data:dependencies}
{zone-data}

{zone-data:operation}
Currently the controller in the url can't have underscores (they are filtered out). This change would keep underscores in place and replace spaces into underscores. The Zend::loadClass has to be adjusted as well so it can use subdirectories when the dirs parameter is not null.
{zone-data}

{zone-data:class-list}
* Zend
* Zend_Controller_Dispatcher
{zone-data}

{zone-data:use-cases}
Suppose one of the parts of your website is a Forum, then you could have following urls:

forum_topic/list
forum_topic/add
forum_topic/edit
forum_topic/delete

forum_post/list
forum_post/rate
forum_post/view
forum_post/add
forum_post/edit
forum_post/delete

etc...

This would yield in following files

/application/controllers/Forum/TopicController.php => Class Forum_TopicController
/application/controllers/Forum/PostController.php => Class Forum_PostController

{zone-data}

{zone-data:skeletons}
Zend.php : lijn 84, change:
{code}
$file = $class . '.php';
{code}
to:
{code}
if ($path != $class) {
$dirs.= DIRECTORY_SEPARATOR.dirname($path);
$file = basename($path) . '.php';
} else {
$file = $class . '.php';
}
{code}

Zend/Controller/Dispatcher.php: lijn 167, added:

{code}
$className = str_replace("_", DIRECTORY_SEPARATOR, $className);
{code}

Zend/Controller/Dispatcher.php: lijn 91, change
{code}
protected function _formatName($unformatted)
{
$unformatted = str_replace(array('-', '_', '.'), ' ', strtolower($unformatted));
$unformatted = preg_replace('[Zend_Db_Adapter_Odbtp_Mssql^a-z0-9 ]', '', $unformatted);
return str_replace(' ', '', ucwords($unformatted));
}
{code}
to:
{code}
protected function _formatName($unformatted)
{
$unformatted = str_replace(array('-', '_', '%20', '.'), ' ', strtolower($unformatted));
$unformatted = preg_replace('[Zend_Db_Adapter_Odbtp_Mssql^a-z0-9 ]', '', $unformatted);
return str_replace(' ', '_', ucwords($unformatted));
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>