| @@ 16-62 (lines=47) @@ | ||
| 13 | use Symfony\Component\Console\Input\InputInterface; |
|
| 14 | use Symfony\Component\Console\Output\OutputInterface; |
|
| 15 | ||
| 16 | class DisableCommand extends ContainerAwareCommand |
|
| 17 | { |
|
| 18 | /** |
|
| 19 | * @var ManufacturerRepository |
|
| 20 | */ |
|
| 21 | protected $manufacturerRepository; |
|
| 22 | ||
| 23 | public function __construct(ManufacturerRepository $manufacturerRepository) |
|
| 24 | { |
|
| 25 | $this->manufacturerRepository = $manufacturerRepository; |
|
| 26 | ||
| 27 | parent::__construct(); |
|
| 28 | } |
|
| 29 | ||
| 30 | protected function configure() |
|
| 31 | { |
|
| 32 | $this |
|
| 33 | ->setName('loevgaard:dandomain-consignment:disable') |
|
| 34 | ->setDescription('Disables consignment for the specified manufacturer') |
|
| 35 | ->addArgument('manufacturer', InputArgument::REQUIRED, 'The manufacturer') |
|
| 36 | ; |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * @param InputInterface $input |
|
| 41 | * @param OutputInterface $output |
|
| 42 | * |
|
| 43 | * @return int|null|void |
|
| 44 | * |
|
| 45 | * @throws NonExistentManufacturerException |
|
| 46 | * @throws ORMException |
|
| 47 | * @throws OptimisticLockException |
|
| 48 | */ |
|
| 49 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 50 | { |
|
| 51 | // fetch arguments and options |
|
| 52 | $manufacturer = $input->getArgument('manufacturer'); |
|
| 53 | ||
| 54 | // find manufacturer |
|
| 55 | $manufacturer = $this->manufacturerRepository->findOneByExternalId($manufacturer); |
|
| 56 | ||
| 57 | if (!$manufacturer) { |
|
| 58 | throw new NonExistentManufacturerException('The manufacturer does not exist'); |
|
| 59 | } |
|
| 60 | ||
| 61 | $manufacturer->setConsignment(false); |
|
| 62 | $this->manufacturerRepository->flush(); |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||
| @@ 16-62 (lines=47) @@ | ||
| 13 | use Symfony\Component\Console\Input\InputInterface; |
|
| 14 | use Symfony\Component\Console\Output\OutputInterface; |
|
| 15 | ||
| 16 | class EnableCommand extends ContainerAwareCommand |
|
| 17 | { |
|
| 18 | /** |
|
| 19 | * @var ManufacturerRepository |
|
| 20 | */ |
|
| 21 | protected $manufacturerRepository; |
|
| 22 | ||
| 23 | public function __construct(ManufacturerRepository $manufacturerRepository) |
|
| 24 | { |
|
| 25 | $this->manufacturerRepository = $manufacturerRepository; |
|
| 26 | ||
| 27 | parent::__construct(); |
|
| 28 | } |
|
| 29 | ||
| 30 | protected function configure() |
|
| 31 | { |
|
| 32 | $this |
|
| 33 | ->setName('loevgaard:dandomain-consignment:enable') |
|
| 34 | ->setDescription('Enables consignment for the specified manufacturer') |
|
| 35 | ->addArgument('manufacturer', InputArgument::REQUIRED, 'The manufacturer') |
|
| 36 | ; |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * @param InputInterface $input |
|
| 41 | * @param OutputInterface $output |
|
| 42 | * |
|
| 43 | * @return int|null|void |
|
| 44 | * |
|
| 45 | * @throws NonExistentManufacturerException |
|
| 46 | * @throws ORMException |
|
| 47 | * @throws OptimisticLockException |
|
| 48 | */ |
|
| 49 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 50 | { |
|
| 51 | // fetch arguments and options |
|
| 52 | $manufacturer = $input->getArgument('manufacturer'); |
|
| 53 | ||
| 54 | // find manufacturer |
|
| 55 | $manufacturer = $this->manufacturerRepository->findOneByExternalId($manufacturer); |
|
| 56 | ||
| 57 | if (!$manufacturer) { |
|
| 58 | throw new NonExistentManufacturerException('The manufacturer does not exist'); |
|
| 59 | } |
|
| 60 | ||
| 61 | $manufacturer->setConsignment(true); |
|
| 62 | $this->manufacturerRepository->flush(); |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||