1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2017 SURFnet B.V. |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command; |
20
|
|
|
|
21
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
22
|
|
|
use Symfony\Component\Console\Helper\QuestionHelper; |
23
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
24
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
25
|
|
|
use Symfony\Component\Console\Question\ChoiceQuestion; |
26
|
|
|
|
27
|
|
|
class ReplaySpecificEventsCommand extends ContainerAwareCommand |
28
|
|
|
{ |
29
|
|
|
protected function configure() |
30
|
|
|
{ |
31
|
|
|
$this |
32
|
|
|
->setName('stepup:event:replay') |
33
|
|
|
->setDescription('replay specified events for specified projectors'); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function execute(InputInterface $input, OutputInterface $output) |
37
|
|
|
{ |
38
|
|
|
$container = $this->getContainer(); |
39
|
|
|
$eventCollection = $container->get('middleware.event_replay.event_collection'); |
40
|
|
|
|
41
|
|
|
/** @var QuestionHelper $questionHelper */ |
42
|
|
|
$questionHelper = $this->getHelper('question'); |
43
|
|
|
|
44
|
|
|
$selectEventsQuestion = new ChoiceQuestion( |
45
|
|
|
'Which events would you like to replay? Please supply a comma-separated list of numbers.', |
46
|
|
|
iterator_to_array($eventCollection) |
47
|
|
|
); |
48
|
|
|
$selectEventsQuestion->setMultiselect(true); |
49
|
|
|
|
50
|
|
|
$chosenEvents = $questionHelper->ask($input, $output, $selectEventsQuestion); |
51
|
|
|
$eventCollection->select($chosenEvents); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|