|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the zibios/sharep. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Zbigniew Ślązak |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace App\Slack\SlashCommand\Sharep; |
|
12
|
|
|
|
|
13
|
|
|
use App\Slack\MessageBuilder\Layout; |
|
14
|
|
|
use App\Slack\MessageBuilder\MessageFactory; |
|
15
|
|
|
use App\Slack\SlashCommand\Data\CommandData; |
|
16
|
|
|
use App\Slack\SlashCommand\TaskProcessorInterface; |
|
17
|
|
|
|
|
18
|
|
|
class SharepReleaseTaskProcessor implements TaskProcessorInterface |
|
19
|
|
|
{ |
|
20
|
|
|
/** @var MessageFactory */ |
|
21
|
|
|
private $messageFactory; |
|
22
|
|
|
|
|
23
|
3 |
|
public function __construct(MessageFactory $messageFactory) |
|
24
|
|
|
{ |
|
25
|
3 |
|
$this->messageFactory = $messageFactory; |
|
26
|
3 |
|
} |
|
27
|
|
|
|
|
28
|
2 |
|
public function supports(CommandData $commandData): bool |
|
29
|
|
|
{ |
|
30
|
2 |
|
return (bool) preg_match("/^release\s?/i", $commandData->text); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
1 |
|
public function process(CommandData $commandData): Layout |
|
34
|
|
|
{ |
|
35
|
1 |
|
$mf = $this->messageFactory; |
|
36
|
|
|
|
|
37
|
1 |
|
return $mf->layout( |
|
38
|
1 |
|
$mf->blockSection( |
|
39
|
1 |
|
$mf->elementPlainText('Please select dates to release'), |
|
40
|
1 |
|
$mf->elementMultiSelectStaticGroup( |
|
41
|
1 |
|
'Select dates', |
|
42
|
1 |
|
'sharep-release-multiselect-dates', |
|
43
|
1 |
|
[], |
|
44
|
1 |
|
null, |
|
45
|
1 |
|
$mf->objectOptionGroup( |
|
46
|
1 |
|
'Week 41', |
|
47
|
1 |
|
$mf->objectOption('Mo 2019-11-11', '2019-11-11'), |
|
48
|
1 |
|
$mf->objectOption('Tu 2019-11-12', '2019-11-12'), |
|
49
|
1 |
|
$mf->objectOption('We 2019-11-13', '2019-11-13'), |
|
50
|
1 |
|
$mf->objectOption('Th 2019-11-14', '2019-11-14'), |
|
51
|
1 |
|
$mf->objectOption('Fr 2019-11-15', '2019-11-15'), |
|
52
|
|
|
), |
|
|
|
|
|
|
53
|
1 |
|
$mf->objectOptionGroup( |
|
54
|
1 |
|
'Week 42', |
|
55
|
1 |
|
$mf->objectOption('Mo 2019-11-18', '2019-11-18'), |
|
56
|
1 |
|
$mf->objectOption('Tu 2019-11-19', '2019-11-19'), |
|
57
|
1 |
|
$mf->objectOption('We 2019-11-20', '2019-11-20'), |
|
58
|
1 |
|
$mf->objectOption('Th 2019-11-21', '2019-11-21'), |
|
59
|
1 |
|
$mf->objectOption('Fr 2019-11-22', '2019-11-22'), |
|
60
|
|
|
), |
|
61
|
|
|
) |
|
62
|
|
|
) |
|
63
|
|
|
); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|