lithium\action\Dispatcher::config PHP Method

config() public static method

Used to set configuration parameters for the Dispatcher.
See also: lithium\action\Dispatcher::$_rules
public static config ( array $config = [] ) : array
$config array Possible key settings are `'classes'` which sets the class dependencies for `Dispatcher` (i.e. `'request'` or `'router'`) and `'rules'`, which sets the pre-processing rules for routing parameters. For more information on the `'rules'` setting, see the `$_rules` property.
return array If no parameters are passed, returns an associative array with the current configuration, otherwise returns `null`.
    public static function config(array $config = array())
    {
        if (!$config) {
            return array('rules' => static::$_rules);
        }
        foreach ($config as $key => $val) {
            $key = "_{$key}";
            if (!is_array($val)) {
                static::${$key} = $val;
                continue;
            }
            if (isset(static::${$key})) {
                static::${$key} = $val + static::${$key};
            }
        }
    }

Usage Example

コード例 #1
0
ファイル: DispatcherTest.php プロジェクト: nashadalam/lithium
 public function testPluginControllerLookupFail()
 {
     Dispatcher::config(array('classes' => array('router' => __CLASS__)));
     $this->expectException("/Controller `some_invalid_plugin.Controller` not found/");
     Dispatcher::run(new Request(array('url' => '/plugin')));
 }
All Usage Examples Of lithium\action\Dispatcher::config