Пример #1
0
 public function testAddServiceConfigurationsOverwrites()
 {
     $this->object->get('foo2');
     $this->object->addServiceConfigurations(array('foo2' => array('class' => self::BAR_CLASS, 'constructor_parameters' => array(array('type' => 'service', 'id' => 'foo'), array('type' => 'constant', 'value' => 'string')))));
     $bar = $this->object->get('foo2');
     $this->assertInstanceOf(self::BAR_CLASS, $bar, 'The element whose configuration has changed should be of class "Bar". If there was an instance of the ' . 'previous configuration, it shouldn\'t have been used.');
 }
Пример #2
0
 /**
  * Run the Dispatcher for the received Request to the webserver.
  */
 public function run()
 {
     $router = $this->container->get('router');
     $controller_factory = $this->container->get('factory.controller');
     try {
         $routing_info = $router->parseRequest($this->container->get('request'));
         $controller = $controller_factory->build(array('class' => $routing_info['controller']));
         $action_to_call = array($controller, $routing_info['action'] . 'Action');
         if (!is_callable($action_to_call)) {
             throw new DispatcherException("The given action ({$routing_info['controller']}::{$action_to_call[1]})" . "  can't be called.");
         }
         call_user_func_array($action_to_call, $routing_info['params']);
         $controller->render()->send();
     } catch (RouteNotFoundException $e) {
         $this->handleError($controller_factory, $e, 'error404Action');
     } catch (\Exception $e) {
         $this->handleError($controller_factory, $e, 'error5xxAction');
     }
 }