/**
  * {@inheritdoc}
  *
  * @throws \LogicException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     $name = $input->getArgument('name');
     if (empty($name)) {
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $configuration = $extension->getConfiguration(array(), $this->getContainerBuilder());
     $this->validateConfiguration($extension, $configuration);
     if ($name === $extension->getAlias()) {
         $message = sprintf('Weather configuration for extension with alias: "%s"', $name);
     } else {
         $message = sprintf('Weather configuration for "%s"', $name);
     }
     switch ($input->getOption('format')) {
         case 'yaml':
             $output->writeln(sprintf('# %s', $message));
             $dumper = new YamlReferenceDumper();
             break;
         case 'xml':
             $output->writeln(sprintf('<!-- %s -->', $message));
             $dumper = new XmlReferenceDumper();
             break;
         default:
             $output->writeln($message);
             throw new \InvalidArgumentException('Only the yaml and xml formats are supported.');
     }
     $output->writeln($dumper->dump($configuration, $extension->getNamespace()));
 }
 /**
  * {@inheritdoc}
  *
  * @throws \LogicException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     if (null === ($name = $input->getArgument('name'))) {
         $this->listBundles($io);
         $io->comment('Provide the name of a bundle as the first argument of this command to dump its default configuration. (e.g. <comment>config:dump-reference FrameworkBundle</comment>)');
         return;
     }
     $extension = $this->findExtension($name);
     $configuration = $extension->getConfiguration(array(), $this->getContainerBuilder());
     $this->validateConfiguration($extension, $configuration);
     if ($name === $extension->getAlias()) {
         $message = sprintf('Default configuration for extension with alias: "%s"', $name);
     } else {
         $message = sprintf('Default configuration for "%s"', $name);
     }
     switch ($input->getOption('format')) {
         case 'yaml':
             $io->writeln(sprintf('# %s', $message));
             $dumper = new YamlReferenceDumper();
             break;
         case 'xml':
             $io->writeln(sprintf('<!-- %s -->', $message));
             $dumper = new XmlReferenceDumper();
             break;
         default:
             $io->writeln($message);
             throw new \InvalidArgumentException('Only the yaml and xml formats are supported.');
     }
     $io->writeln($dumper->dump($configuration, $extension->getNamespace()));
 }
 public function testNamespaceDumper()
 {
     $configuration = new ExampleConfiguration();
     $dumper = new XmlReferenceDumper();
     $this->assertEquals(str_replace('http://example.org/schema/dic/acme_root', 'http://symfony.com/schema/dic/symfony', $this->getConfigurationAsString()), $dumper->dump($configuration, 'http://symfony.com/schema/dic/symfony'));
 }
 /**
  * {@inheritdoc}
  *
  * @throws \LogicException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $bundles = $this->getContainer()->get('kernel')->getBundles();
     $containerBuilder = $this->getContainerBuilder();
     $name = $input->getArgument('name');
     if (empty($name)) {
         $output->writeln('Available registered bundles with their extension alias if available:');
         $table = $this->getHelperSet()->get('table');
         $table->setHeaders(array('Bundle name', 'Extension alias'));
         foreach ($bundles as $bundle) {
             $extension = $bundle->getContainerExtension();
             $table->addRow(array($bundle->getName(), $extension ? $extension->getAlias() : ''));
         }
         $table->render($output);
         return;
     }
     $extension = null;
     if (preg_match('/Bundle$/', $name)) {
         // input is bundle name
         if (isset($bundles[$name])) {
             $extension = $bundles[$name]->getContainerExtension();
         }
         if (!$extension) {
             throw new \LogicException(sprintf('No extensions with configuration available for "%s"', $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(sprintf('No extension with alias "%s" is enabled', $name));
         }
         $message = 'Default configuration for extension with alias: "' . $name . '"';
     }
     $configuration = $extension->getConfiguration(array(), $containerBuilder);
     if (!$configuration) {
         throw new \LogicException(sprintf('The extension with alias "%s" does not have it\'s getConfiguration() method setup', $extension->getAlias()));
     }
     if (!$configuration instanceof ConfigurationInterface) {
         throw new \LogicException(sprintf('Configuration class "%s" should implement ConfigurationInterface in order to be dumpable', get_class($configuration)));
     }
     switch ($input->getOption('format')) {
         case 'yaml':
             $output->writeln(sprintf('# %s', $message));
             $dumper = new YamlReferenceDumper();
             break;
         case 'xml':
             $output->writeln(sprintf('<!-- %s -->', $message));
             $dumper = new XmlReferenceDumper();
             break;
         default:
             $output->writeln($message);
             throw new \InvalidArgumentException('Only the yaml and xml formats are supported.');
     }
     $output->writeln($dumper->dump($configuration, $extension->getNamespace()));
 }