|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Scrumban\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
6
|
|
|
use Symfony\Component\DependencyInjection\Extension\Extension; |
|
7
|
|
|
|
|
8
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
9
|
|
|
use Symfony\Component\Config\FileLocator; |
|
10
|
|
|
|
|
11
|
|
|
use Scrumban\Model\CardInterface; |
|
12
|
|
|
|
|
13
|
|
|
class ScrumbanExtension extends Extension |
|
14
|
|
|
{ |
|
15
|
|
|
const TRELLO_DEFAULT_COLUMNS = [ |
|
16
|
|
|
'ready' => [ |
|
17
|
|
|
'name' => 'ready', |
|
18
|
|
|
'type' => CardInterface::CARD_TYPE_US, |
|
19
|
|
|
'status' => CardInterface::STATUS_READY, |
|
20
|
|
|
], |
|
21
|
|
|
'todo' => [ |
|
22
|
|
|
'name' => 'todo', |
|
23
|
|
|
'type' => CardInterface::CARD_TYPE_US, |
|
24
|
|
|
'status' => CardInterface::STATUS_TODO, |
|
25
|
|
|
], |
|
26
|
|
|
'in_progress' => [ |
|
27
|
|
|
'name' => 'in_progress', |
|
28
|
|
|
'type' => CardInterface::CARD_TYPE_US, |
|
29
|
|
|
'status' => CardInterface::STATUS_IN_PROGRESS, |
|
30
|
|
|
], |
|
31
|
|
|
'review' => [ |
|
32
|
|
|
'name' => 'review', |
|
33
|
|
|
'type' => CardInterface::CARD_TYPE_US, |
|
34
|
|
|
'status' => CardInterface::STATUS_REVIEW, |
|
35
|
|
|
], |
|
36
|
|
|
'to_release' => [ |
|
37
|
|
|
'name' => 'to_release', |
|
38
|
|
|
'type' => CardInterface::CARD_TYPE_US, |
|
39
|
|
|
'status' => CardInterface::STATUS_TO_RELEASE, |
|
40
|
|
|
], |
|
41
|
|
|
'done' => [ |
|
42
|
|
|
'name' => 'done', |
|
43
|
|
|
'type' => CardInterface::CARD_TYPE_US, |
|
44
|
|
|
'status' => CardInterface::STATUS_DONE, |
|
45
|
|
|
] |
|
46
|
|
|
]; |
|
47
|
|
|
|
|
48
|
|
|
public function load(array $configs, ContainerBuilder $container) |
|
49
|
|
|
{ |
|
50
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(dirname(__DIR__).'/Resources/config')); |
|
51
|
|
|
$loader->load('services.yaml'); |
|
52
|
|
|
|
|
53
|
|
|
$configuration = new TrelloConfiguration(); |
|
54
|
|
|
|
|
55
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
56
|
|
|
if (!empty($config['trello'])) { |
|
57
|
|
|
$this->loadTrelloConfiguration($config['trello'], $container); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function loadTrelloConfiguration(array $config, ContainerBuilder $container) |
|
62
|
|
|
{ |
|
63
|
|
|
$container->setParameter('scrumban.trello.boards', $config['boards']); |
|
64
|
|
|
$container->setParameter('scrumban.trello.columns', array_merge(self::TRELLO_DEFAULT_COLUMNS, $config['columns'] ?? [])); |
|
65
|
|
|
|
|
66
|
|
|
$container->getDefinition(\Scrumban\Registry\TrelloRegistry::class)->setPublic(true); |
|
67
|
|
|
$container->getDefinition(\Scrumban\Gateway\TrelloGateway::class)->setPublic(true); |
|
68
|
|
|
|
|
69
|
|
|
if (isset($config['has_plus_for_trello'])) { |
|
70
|
|
|
$container->getDefinition('scrumban.trello_manager')->setProperty('hasPlusForTrello', $config['has_plus_for_trello']); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
} |