public function testFormatNoSuggestion() { $message = 'This is a message'; $suggestion = new ConfigSuggestion($message); $formatter = new YamlSuggestionFormatter(); $this->assertSame($message, $formatter->format($suggestion)); }
public function testFormat() { $message = <<<EOT Database configuration has changed for eZ Content repository. Please define: - An entry in ezpublish.repositories - A Doctrine connection (You may check configuration reference for Doctrine "config:dump-reference doctrine" console command.) - A reference to configured repository in ezpublish.system.foo.repository EOT; $suggestion = new ConfigSuggestion($message); $suggestion->setMandatory(true); $suggestionArray = array('doctrine' => array('dbal' => array('connections' => array('default' => array('driver' => 'pdo_mysql', 'host' => 'localhost', 'dbname' => 'my_database', 'user' => 'my_user', 'password' => 'some_password', 'charset' => 'UTF8')))), 'ezpublish' => array('repositories' => array('my_repository' => array('engine' => 'legacy', 'connection' => 'default')), 'system' => array('foo' => array('repository' => 'my_repository')))); $suggestion->setSuggestion($suggestionArray); $expectedMessage = <<<EOT Database configuration has changed for eZ Content repository. Please define: - An entry in ezpublish.repositories - A Doctrine connection (You may check configuration reference for Doctrine "config:dump-reference doctrine" console command.) - A reference to configured repository in ezpublish.system.foo.repository Example: ======== doctrine: dbal: connections: default: driver: pdo_mysql host: localhost dbname: my_database user: my_user password: some_password charset: UTF8 ezpublish: repositories: my_repository: engine: legacy connection: default system: foo: repository: my_repository EOT; $formatter = new YamlSuggestionFormatter(); $this->assertSame($expectedMessage, trim($formatter->format($suggestion))); }
/** * Loads a specific configuration. * * @param mixed[] $configs An array of configuration values * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container A ContainerBuilder instance * * @throws \InvalidArgumentException When provided tag is not defined in this extension * * @api */ public function load(array $configs, ContainerBuilder $container) { $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $configuration = $this->getConfiguration($configs, $container); // Note: this is where the transformation occurs $config = $this->processConfiguration($configuration, $configs); // Base services and services overrides $loader->load('services.yml'); // Security services $loader->load('security.yml'); // Slots $loader->load('slot.yml'); // Default settings $loader->load('default_settings.yml'); $this->registerRepositoriesConfiguration($config, $container); $this->registerSiteAccessConfiguration($config, $container); $this->registerImageMagickConfiguration($config, $container); $this->registerPageConfiguration($config, $container); // Routing $this->handleRouting($config, $container, $loader); // Public API loading $this->handleApiLoading($container, $loader); $this->handleTemplating($container, $loader); $this->handleSessionLoading($container, $loader); $this->handleCache($config, $container, $loader); $this->handleLocale($config, $container, $loader); $this->handleHelpers($config, $container, $loader); $this->handleImage($config, $container, $loader); // Map settings $processor = new ConfigurationProcessor($container, 'ezsettings'); $processor->mapConfig($config, $this->configParser); if ($this->suggestionCollector->hasSuggestions()) { $message = ''; $suggestionFormatter = new YamlSuggestionFormatter(); foreach ($this->suggestionCollector->getSuggestions() as $suggestion) { $message .= $suggestionFormatter->format($suggestion) . "\n\n"; } throw new InvalidArgumentException($message); } $this->handleSiteAccessesRelation($container); }