Issues

ZF-2390: Easier overloading for Zend_Controller_Dispatcher_Standard

Description

This patch enables easier overloading for Zend_Controller_Dispatcher_Standard. It helps someone to implement an extended dispatcher which simply changes the way the class formatting is done.

Comments

Add Zend_Controller_Dispatcher_Standard::formatClassName() to allow easy overloading of the class formatting facility.

Can you provide the use case (code) that would require this change (or that this change would facilitate)?

There are two use cases:

Using a different separator:


class MyDispatcher extends Zend_Controller_Dispatcher
{
    public function formatClassName($module, $class)
    {
        return $this->formatModuleName($module) . '::' . $class;
    }

    public function classToFilename($class)
    {
        return str_replace('::', DIRECTORY_SEPARATOR, $class) . '.php';
    }
}

Having a default prefix:


class MyDispatcher extends Zend_Controller_Dispatcher
{
    protected $_prefix;

    public function setPrefix($prefix)
    {
        $this->_prefix;
        return $this;
    }

    public function getPrefix()
    {
         return $this->_prefix;
    }

    public function formatClassName($module, $class)
    {
        return $this->getPrefix() . '::' . $this->formatModuleName($module) . '::' . $class;
    }

    public function classToFilename($class)
    {
        return str_replace('::', DIRECTORY_SEPARATOR, $class) . '.php';
    }
}

Scheduling for 1.5.0

Applied in trunk; thanks for the patch!