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