@@ 11-46 (lines=36) @@ | ||
8 | use Symfony\Component\Console\Input\InputInterface; |
|
9 | use Symfony\Component\Console\Output\OutputInterface; |
|
10 | ||
11 | class ArticleCommand extends BaseCommand |
|
12 | { |
|
13 | use NewsClientCommandTrait; |
|
14 | ||
15 | protected function configure() |
|
16 | { |
|
17 | parent::configure(); |
|
18 | ||
19 | $this |
|
20 | ->setName('news:article:id') |
|
21 | ->addArgument( |
|
22 | 'id', |
|
23 | InputArgument::REQUIRED, |
|
24 | 'Article ID' |
|
25 | ); |
|
26 | } |
|
27 | ||
28 | /** |
|
29 | * @param InputInterface $input |
|
30 | * @param OutputInterface $output |
|
31 | * @return int |
|
32 | */ |
|
33 | protected function execute(InputInterface $input, OutputInterface $output) |
|
34 | { |
|
35 | $newsClient = $this->getNewsClient($input); |
|
36 | ||
37 | $articleId = $input->getArgument('id'); |
|
38 | ||
39 | $result = $newsClient->getArticle($articleId); |
|
40 | $formatter = Formatter::make($result, Formatter::ARR); |
|
41 | ||
42 | $output->writeln($formatter->toYaml()); |
|
43 | ||
44 | return 0; |
|
45 | } |
|
46 | } |
|
47 |
@@ 11-46 (lines=36) @@ | ||
8 | use Symfony\Component\Console\Input\InputInterface; |
|
9 | use Symfony\Component\Console\Output\OutputInterface; |
|
10 | ||
11 | class SearchCollectionCommand extends BaseCommand |
|
12 | { |
|
13 | use NewsClientCommandTrait; |
|
14 | ||
15 | protected function configure() |
|
16 | { |
|
17 | parent::configure(); |
|
18 | ||
19 | $this |
|
20 | ->setName('news:search:collection') |
|
21 | ->addArgument( |
|
22 | 'ids', |
|
23 | InputArgument::REQUIRED | InputArgument::IS_ARRAY, |
|
24 | 'Content IDs' |
|
25 | ); |
|
26 | } |
|
27 | ||
28 | /** |
|
29 | * @param InputInterface $input |
|
30 | * @param OutputInterface $output |
|
31 | * @return int |
|
32 | */ |
|
33 | protected function execute(InputInterface $input, OutputInterface $output) |
|
34 | { |
|
35 | $newsClient = $this->getNewsClient($input); |
|
36 | ||
37 | $contentIds = $input->getArgument('ids'); |
|
38 | ||
39 | $result = $newsClient->searchByCollection($contentIds); |
|
40 | $formatter = Formatter::make($result, Formatter::ARR); |
|
41 | ||
42 | $output->writeln($formatter->toYaml()); |
|
43 | ||
44 | return 0; |
|
45 | } |
|
46 | } |
|
47 |
@@ 11-46 (lines=36) @@ | ||
8 | use Symfony\Component\Console\Input\InputInterface; |
|
9 | use Symfony\Component\Console\Output\OutputInterface; |
|
10 | ||
11 | class SectionByIdCommand extends BaseCommand |
|
12 | { |
|
13 | use NewsClientCommandTrait; |
|
14 | ||
15 | protected function configure() |
|
16 | { |
|
17 | parent::configure(); |
|
18 | ||
19 | $this |
|
20 | ->setName('news:section:id') |
|
21 | ->addArgument( |
|
22 | 'id', |
|
23 | InputArgument::REQUIRED, |
|
24 | 'Section ID' |
|
25 | ); |
|
26 | } |
|
27 | ||
28 | /** |
|
29 | * @param InputInterface $input |
|
30 | * @param OutputInterface $output |
|
31 | * @return int |
|
32 | */ |
|
33 | protected function execute(InputInterface $input, OutputInterface $output) |
|
34 | { |
|
35 | $newsClient = $this->getNewsClient($input); |
|
36 | ||
37 | $sectionId = $input->getArgument('id'); |
|
38 | ||
39 | $result = $newsClient->getSectionById($sectionId); |
|
40 | $formatter = Formatter::make($result, Formatter::ARR); |
|
41 | ||
42 | $output->writeln($formatter->toYaml()); |
|
43 | ||
44 | return 0; |
|
45 | } |
|
46 | } |
|
47 |
@@ 11-46 (lines=36) @@ | ||
8 | use Symfony\Component\Console\Input\InputInterface; |
|
9 | use Symfony\Component\Console\Output\OutputInterface; |
|
10 | ||
11 | class SectionByUniqueNameCommand extends BaseCommand |
|
12 | { |
|
13 | use NewsClientCommandTrait; |
|
14 | ||
15 | protected function configure() |
|
16 | { |
|
17 | parent::configure(); |
|
18 | ||
19 | $this |
|
20 | ->setName('news:section:uniquename') |
|
21 | ->addArgument( |
|
22 | 'name', |
|
23 | InputArgument::REQUIRED, |
|
24 | 'Unique section name' |
|
25 | ); |
|
26 | } |
|
27 | ||
28 | /** |
|
29 | * @param InputInterface $input |
|
30 | * @param OutputInterface $output |
|
31 | * @return int |
|
32 | */ |
|
33 | protected function execute(InputInterface $input, OutputInterface $output) |
|
34 | { |
|
35 | $newsClient = $this->getNewsClient($input); |
|
36 | ||
37 | $sectionName = $input->getArgument('name'); |
|
38 | ||
39 | $result = $newsClient->getSectionByUniqueName($sectionName); |
|
40 | $formatter = Formatter::make($result, Formatter::ARR); |
|
41 | ||
42 | $output->writeln($formatter->toYaml()); |
|
43 | ||
44 | return 0; |
|
45 | } |
|
46 | } |
|
47 |
@@ 11-46 (lines=36) @@ | ||
8 | use Symfony\Component\Console\Input\InputInterface; |
|
9 | use Symfony\Component\Console\Output\OutputInterface; |
|
10 | ||
11 | class SubsectionsListCommand extends BaseCommand |
|
12 | { |
|
13 | use NewsClientCommandTrait; |
|
14 | ||
15 | protected function configure() |
|
16 | { |
|
17 | parent::configure(); |
|
18 | ||
19 | $this |
|
20 | ->setName('news:subsections:list') |
|
21 | ->addArgument( |
|
22 | 'sectionId', |
|
23 | InputArgument::REQUIRED, |
|
24 | 'Section ID' |
|
25 | ); |
|
26 | } |
|
27 | ||
28 | /** |
|
29 | * @param InputInterface $input |
|
30 | * @param OutputInterface $output |
|
31 | * @return int |
|
32 | */ |
|
33 | protected function execute(InputInterface $input, OutputInterface $output) |
|
34 | { |
|
35 | $newsClient = $this->getNewsClient($input); |
|
36 | ||
37 | $sectionId = $input->getArgument('sectionId'); |
|
38 | ||
39 | $result = $newsClient->getSubsectionsList($sectionId); |
|
40 | $formatter = Formatter::make($result, Formatter::ARR); |
|
41 | ||
42 | $output->writeln($formatter->toYaml()); |
|
43 | ||
44 | return 0; |
|
45 | } |
|
46 | } |
|
47 |