FOF30\Factory\Magic\DispatcherFactory::make PHP Method

make() public method

Create a new object instance
public make ( array $config = [] ) : Dispatcher
$config array The config parameters which override the fof.xml information
return FOF30\Dispatcher\Dispatcher A new Dispatcher object
    public function make(array $config = array())
    {
        $appConfig = $this->container->appConfig;
        $defaultConfig = $appConfig->get('dispatcher.*');
        $config = array_merge($defaultConfig, $config);
        $className = $this->container->getNamespacePrefix($this->getSection()) . 'Dispatcher\\DefaultDispatcher';
        if (!class_exists($className, true)) {
            $className = '\\FOF30\\Dispatcher\\Dispatcher';
        }
        $dispatcher = new $className($this->container, $config);
        return $dispatcher;
    }

Usage Example

示例#1
0
 /**
  * @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'));
 }
All Usage Examples Of FOF30\Factory\Magic\DispatcherFactory::make
DispatcherFactory