/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { if (class_exists('Symfony\\Component\\Config\\Definition\\Dumper\\YamlReferenceDumper')) { $dumper = new YamlReferenceDumper(); } else { // Support Symfony Config 2.3 $dumper = new ReferenceDumper(); } $configTree = new ConfigurationTree(); $output->writeln($dumper->dumpNode($configTree->getConfigTree($this->extensionManager->getExtensions()))); }
/** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $bundles = $this->getContainer()->get('kernel')->getBundles(); $containerBuilder = $this->getContainerBuilder(); $name = $input->getArgument('name'); $extension = null; if (preg_match('/Bundle$/', $name)) { // input is bundle name if (isset($bundles[$name])) { $extension = $bundles[$name]->getContainerExtension(); } if (!$extension) { throw new \LogicException('No extensions with configuration available for "' . $name . '"'); } $message = 'Default configuration for "' . $name . '"'; } else { foreach ($bundles as $bundle) { $extension = $bundle->getContainerExtension(); if ($extension && $extension->getAlias() === $name) { break; } $extension = null; } if (!$extension) { throw new \LogicException('No extension with alias "' . $name . '" is enabled'); } $message = 'Default configuration for extension with alias: "' . $name . '"'; } $configuration = $extension->getConfiguration(array(), $containerBuilder); if (!$configuration) { throw new \LogicException('The extension with alias "' . $extension->getAlias() . '" does not have it\'s getConfiguration() method setup'); } if (!$configuration instanceof ConfigurationInterface) { throw new \LogicException('Configuration class "' . get_class($configuration) . '" should implement ConfigurationInterface in order to be dumpable'); } $output->writeln($message); $dumper = new ReferenceDumper(); $output->writeln($dumper->dump($configuration)); }
public function testDumper() { $configuration = new ExampleConfiguration(); $dumper = new ReferenceDumper(); $this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration)); }