protected function execute(InputInterface $input, OutputInterface $output) { if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) { $rows = array(); foreach ($this->instances->findAll() as $instance) { $rows[] = array('root', $instance->getRoot()); $rows[] = array('name', $instance->getName()); $rows[] = array('dsn', $instance->getDsn()); $rows[] = array('url', $instance->getUrl()); $rows[] = array('', ''); } /** @var $table \Symfony\Component\Console\Helper\TableHelper */ $table = $this->getApplication()->getHelperSet()->get('table'); $table->setHeaders(array('Property', 'Value')); $table->setRows($rows); $table->render($output); } else { $rows = array(); foreach ($this->instances->findAll() as $instance) { $rows[] = array($instance->getRoot(), $instance->getName(), $instance->getDsn() ? 'y' : '', $instance->getUrl() ? 'y' : ''); } /** @var $table \Symfony\Component\Console\Helper\TableHelper */ $table = $this->getApplication()->getHelperSet()->get('table'); $table->setHeaders(array('Root', 'Name', 'DB', 'Web')); $table->setRows($rows); $table->render($output); $output->writeln('For more detailed info, use "amp show -v" or "amp export [--root=X] [---name=X]'); } }
protected function execute(InputInterface $input, OutputInterface $output) { $this->instances->lock(); $count = 0; foreach ($this->instances->findAll() as $instance) { if ($input->getOption('force') || !file_exists($instance->getRoot())) { $output->writeln("Destroy (root={$instance->getRoot()}, name={$instance->getName()}, dsn={$instance->getDsn()})"); $this->instances->remove($instance->getId()); $count++; } else { $output->writeln("Skip (root={$instance->getRoot()}, name={$instance->getName()}, dsn={$instance->getDsn()})"); } } $output->writeln("Destroyed {$count} instance(s)"); $this->instances->save(); }