public function createService(ServiceLocatorInterface $serviceLocator) { if (!$serviceLocator->has('configType')) { return false; } $type = $serviceLocator->get('configType'); if ($type === 'file') { if (!$serviceLocator->has('configFiles')) { return false; } $configFiles = $serviceLocator->get('configFiles'); if (!function_exists('yaml_parse')) { \Zend\Config\Factory::registerReader('yaml', new \Zend\Config\Reader\Yaml('\\Symfony\\Component\\Yaml\\Yaml::parse')); } $config = Factory::fromFiles($configFiles); return $config; } // @todo config type : string return false; }
public function testFactoryCanRegisterCustomReaderPlugn() { $dummyReader = new Reader\TestAssets\DummyReader(); Factory::getReaderPluginManager()->setService('DummyReader', $dummyReader); Factory::registerReader('dum', 'DummyReader'); $configObject = Factory::fromFile(__DIR__ . '/TestAssets/dummy.dum', true); $this->assertInstanceOf('Zend\\Config\\Config', $configObject); $this->assertEquals($configObject['one'], 1); }