Ouzo\Controller::createInstance PHP Method

createInstance() public static method

public static createInstance ( RouteRule $routeRule )
$routeRule Ouzo\Routing\RouteRule
    public static function createInstance(RouteRule $routeRule)
    {
        $className = get_called_class();
        /** @var $controller Controller */
        $controller = new $className();
        $controller->initialize($routeRule);
        return $controller;
    }

Usage Example

Example #1
0
 /**
  * @test
  */
 public function shouldNotStoreEmptyUrlForNotices()
 {
     //given
     Config::overridePropertyArray(array('global', 'prefix_system'), 'prefix');
     $_SESSION = array();
     $controller = Controller::createInstance(new RouteRule('', '', '', '', false));
     //when
     $controller->notice('hello');
     //then
     Assert::thatArray(Session::get('messages'))->containsOnly(new Notice('hello', null));
     Config::revertPropertyArray(array('global', 'prefix_system'));
 }