protected function execute(InputInterface $input, OutputInterface $output) { $counterManager = $this->getContainer()->get('counter_management.manager'); $type = $input->getArgument('type'); if (!$counterManager->hasProvider($type)) { throw new \InvalidArgumentException(sprintf('Provider with %s identity not found', $type)); } $name = $input->getArgument('name'); $site = $input->getArgument('site'); $webCounter = new WebCounter(); $webCounter->setName($name); $webCounter->setSite($site); $webCounter->setPushToRemote(true); $webCounter->setTypeKey($type); $webCounter->save(); }