FOF30\Factory\SwitchFactory::dispatcher PHP Метод

dispatcher() публичный Метод

Creates a new Dispatcher
public dispatcher ( array $config = [] ) : Dispatcher
$config array The configuration values for the Dispatcher object
Результат FOF30\Dispatcher\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 default Dispatcher
            return new Dispatcher($this->container, $config);
        }
    }

Usage Example

Пример #1
0
 /**
  * @group           SwitchFactory
  * @covers          FOF30\Factory\SwitchFactory::dispatcher
  * @dataProvider    SwitchFactoryDataprovider::getTestDispatcher
  */
 public function testDispatcher($test, $check)
 {
     $msg = 'SwitchFactory::dispatcher %s - Case: ' . $check['case'];
     $container = new TestContainer(array('componentName' => $test['component']));
     $platform = $container->platform;
     $platform::$isAdmin = $test['backend'];
     $factory = new SwitchFactory($container);
     $result = $factory->dispatcher();
     $this->assertEquals($check['result'], get_class($result), sprintf($msg, 'Returned the wrong result'));
 }