ImportUnitsCommand.php (1030B)
1 <?php 2 3 namespace PartKeepr\SetupBundle\Command; 4 5 use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 6 use Symfony\Component\Console\Input\InputInterface; 7 use Symfony\Component\Console\Input\InputOption; 8 use Symfony\Component\Console\Output\OutputInterface; 9 10 class ImportUnitsCommand extends ContainerAwareCommand 11 { 12 public function configure() 13 { 14 parent::configure(); 15 $this->setName('partkeepr:setup:import-units'); 16 $this->setDescription('Imports the default PartKeepr units'); 17 $this->addOption("update", null, InputOption::VALUE_NONE, "Updates existing units"); 18 } 19 20 public function execute(InputInterface $input, OutputInterface $output) 21 { 22 $update = $input->getOption("update"); 23 24 $return = $this->getContainer()->get('partkeepr.setup.unit_service')->importUnits($update); 25 26 $output->writeln(sprintf( 27 '%d units imported, %d existing units skipped', 28 $return['imported'], 29 $return['skipped'] 30 )); 31 } 32 }