/** * @covers FOF30\Factory\Magic\DispatcherFactory::make * @dataProvider getTestMake */ public function testMake($test, $check) { $msg = 'DispatcherFactory::make %s - Case: ' . $check['case']; $config['componentName'] = $test['component']; if ($test['backend_path']) { $config['backEndPath'] = $test['backend_path']; } $container = new TestContainer($config); // Required so we force FOF to read the fof.xml file $dummy = $container->appConfig; $factory = new DispatcherFactory($container); $result = $factory->make(array()); $this->assertEquals($check['result'], get_class($result), sprintf($msg, 'Returned the wrong result')); }
/** * Creates a new Dispatcher * * @param array $config The configuration values for the Dispatcher object * * @return Dispatcher */ public function dispatcher(array $config = array()) { $dispatcherClass = $this->container->getNamespacePrefix($this->getSection()) . 'Dispatcher\\Dispatcher'; try { return $this->createDispatcher($dispatcherClass, $config); } catch (DispatcherNotFound $e) { // Not found. Let's go on. } $dispatcherClass = $this->container->getNamespacePrefix('inverse') . 'Dispatcher\\Dispatcher'; try { return $this->createDispatcher($dispatcherClass, $config); } catch (DispatcherNotFound $e) { // Not found. Return the magically created Dispatcher $magic = new DispatcherFactory($this->container); // Let's pass the section override (if any) $magic->setSection($this->getSection()); return $magic->make($config); } }
public function dispatcher(array $config = array()) { $dispatcherClass = $this->container->getNamespacePrefix() . 'Dispatcher\\Dispatcher'; try { return $this->createDispatcher($dispatcherClass, $config); } catch (DispatcherNotFound $e) { // Not found. Return the magically created Dispatcher $magic = new DispatcherFactory($this->container); return $magic->make($config); } }