|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Cp\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Cp\CapSniffer; |
|
6
|
|
|
use Cp\Provider\TypeProvider; |
|
7
|
|
|
use Symfony\Component\Console\Command\Command; |
|
8
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
9
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
11
|
|
|
use Symfony\Component\Console\Question\ChoiceQuestion; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class SnifferTrainingCommand |
|
15
|
|
|
*/ |
|
16
|
|
|
class SnifferTrainingCommand extends Command |
|
17
|
|
|
{ |
|
18
|
|
|
const FILE_NAME = 'planning.ics'; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var TypeProvider |
|
22
|
|
|
*/ |
|
23
|
|
|
private $typeProvider; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var CapSniffer |
|
27
|
|
|
*/ |
|
28
|
|
|
private $capSniffer; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* SnifferTrainingCommand constructor. |
|
32
|
|
|
* |
|
33
|
|
|
* @param TypeProvider $typeProvider |
|
34
|
|
|
* @param CapSniffer $capSniffer |
|
35
|
|
|
* @param null|string $name |
|
36
|
|
|
*/ |
|
37
|
1 |
|
public function __construct(TypeProvider $typeProvider, CapSniffer $capSniffer, $name = null) |
|
38
|
|
|
{ |
|
39
|
1 |
|
parent::__construct($name); |
|
40
|
1 |
|
$this->typeProvider = $typeProvider; |
|
41
|
1 |
|
$this->capSniffer = $capSniffer; |
|
42
|
1 |
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* {@inheritdoc} |
|
46
|
|
|
*/ |
|
47
|
1 |
|
protected function configure() |
|
48
|
|
|
{ |
|
49
|
1 |
|
$this->setName('cp:sniffer') |
|
50
|
1 |
|
->setDescription('Get training plan by url') |
|
51
|
1 |
|
->addArgument('week', InputArgument::OPTIONAL, 'Number of week', 8) |
|
52
|
1 |
|
->addArgument('seance', InputArgument::OPTIONAL, 'Number of seance', 3) |
|
53
|
|
|
; |
|
54
|
1 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* {@inheritdoc} |
|
58
|
|
|
*/ |
|
59
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
60
|
|
|
{ |
|
61
|
1 |
|
$week = $input->getArgument('week'); |
|
62
|
1 |
|
$seance = $input->getArgument('seance'); |
|
63
|
|
|
|
|
64
|
1 |
|
$typeOfPlan = $this->typeProvider->getTypes(); |
|
65
|
1 |
|
$question = new ChoiceQuestion('Please select a plan', $typeOfPlan, 0); |
|
66
|
1 |
|
$question->setErrorMessage('Plan %s is not valid.'); |
|
67
|
|
|
|
|
68
|
1 |
|
$helper = $this->getHelper('question'); |
|
69
|
1 |
|
$typeName = $helper->ask($input, $output, $question); |
|
70
|
|
|
|
|
71
|
1 |
|
$this->capSniffer->writeCalendar($typeName, $week, $seance); |
|
72
|
|
|
|
|
73
|
1 |
|
$output->writeln('Calendar generate sucessfuly'); |
|
74
|
1 |
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|