Completed
Push — feature/specific-replay/event-... ( 78c154...b47d0d )
by A.
08:12 queued 03:49
created

ReplaySpecificEventsCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 27
rs 10
c 2
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A execute() 0 17 1
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