protected function doExecute(BundleInterface $bundle, $force, $methodToCall, OutputInterface $output) { $starttime = microtime(true); $message = null; if ($force) { $message = "\n\n" . sprintf(' ✓ %s of bundle "%s" started.', ucfirst($this->getCommandType()), $bundle->getId()) . "\n\n"; } else { $message = "\n\n" . sprintf(' ✓ Getting information about %s of bundle "%s"...', $this->getCommandType(), $bundle->getId()) . "\n\n"; } $output->writeln($message); $logs = $this->getContainer()->get('bundle.loader')->{$methodToCall}($bundle, $force); if ($force) { $output->writeln(sprintf(' ✓ %s of bundle "%s" completed in %s.', ucfirst($this->getCommandType()), $bundle->getId(), number_format(microtime(true) - $starttime, 3) . ' s') . "\n\n"); } $output->writeln('SQL:' . (0 < count($logs['sql']) ? '' : ' -')); foreach ($logs['sql'] as $sql) { $output->writeln($sql); } unset($logs['sql']); foreach ($logs as $key => $other) { foreach ((array) $other as $message) { $output->writeln(sprintf('[%s] %s', ucfirst($key), $message)); } } }
/** * It will at least update provided bundle Doctrine entities located into /Entity folder. * * Note that if $force is equal to false it will only return updates informations about your bundle but * it won't execute any SQL statement. * * @param BundleInterface $bundle The bundle to update * @param boolean $force If true it will execute SQL query, default: false * @return array */ public function updateBundle(BundleInterface $bundle, $force = false) { $event = new BundleInstallUpdateEvent($bundle, ['force' => $force, 'logs' => ['sql' => []]]); $this->application->getEventDispatcher()->dispatch(sprintf('bundle.%s.preupdate', $bundle->getId()), $event); $sqls = $this->updateEntitiesSchema($bundle, $force); $this->application->getEventDispatcher()->dispatch(sprintf('bundle.%s.postupdate', $bundle->getId()), $event); return array_merge($event->getLogs(), ['sql' => $sqls]); }