/** * {@inheritDoc} * Add the new bundle to the BundleBundle loader infrastructure instead of main kernel * * @param QuestionHelper $questionHelper dialog * @param InputInterface $input input * @param OutputInterface $output output * @param KernelInterface $kernel kernel * @param string $namespace namespace * @param string $bundle bundle * * @return string[] */ protected function updateKernel(QuestionHelper $questionHelper, InputInterface $input, OutputInterface $output, KernelInterface $kernel, $namespace, $bundle) { // skip if kernel manipulation disabled by options (defaults to true) $doUpdate = $input->getOption('doUpdateKernel'); if ($doUpdate == 'false') { return; } $auto = true; if ($input->isInteractive()) { $auto = $questionHelper->doAsk($output, $questionHelper->getQuestion('Confirm automatic update of your core bundle', 'yes', '?')); } $output->write('Enabling the bundle inside the core bundle: '); $coreBundle = $kernel->getBundle($input->getOption('loaderBundleName')); if (!is_a($coreBundle, '\\Graviton\\BundleBundle\\GravitonBundleInterface')) { throw new \LogicException('GravitonCoreBundle does not implement GravitonBundleInterface'); } $manip = new BundleBundleManipulator($coreBundle); try { $ret = $auto ? $manip->addBundle($namespace . '\\' . $bundle) : false; if (!$ret) { $reflected = new \ReflectionObject($kernel); return array(sprintf('- Edit <comment>%s</comment>', $reflected->getFilename()), ' and add the following bundle in the <comment>GravitonCoreBundle::getBundles()</comment> method:', '', sprintf(' <comment>new %s(),</comment>', $namespace . '\\' . $bundle), ''); } } catch (\RuntimeException $e) { return array(sprintf('Bundle <comment>%s</comment> is already defined in <comment>%s)</comment>.', $namespace . '\\' . $bundle, 'sGravitonCoreBundle::getBundles()'), ''); } }