Pop\Mvc\Router::addControllers PHP Method

addControllers() public method

Add controllers
public addControllers ( array $controller ) : Router
$controller array
return Router
    public function addControllers(array $controller)
    {
        foreach ($controller as $key => $value) {
            if (!isset($this->controllers[$key])) {
                $this->controllers[$key] = $value;
            } else {
                if (is_array($this->controllers[$key]) && is_array($value)) {
                    $this->controllers[$key] = array_merge_recursive($this->controllers[$key], $value);
                } else {
                    $this->controllers[$key] = $value;
                }
            }
        }
        return $this;
    }

Usage Example

Example #1
0
 public function testAddAndGetControllers()
 {
     $r = new Router(array('/' => 'Some\\New\\Controller'));
     $r->addControllers(array('/other' => 'Some\\New\\OtherController'));
     $this->assertEquals(2, count($r->getControllers()));
     $r->addControllers(array('/' => array('/test' => 'Some\\New\\TestController')));
     $this->assertEquals(2, count($r->getControllers()));
 }