1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Superdesk Publisher Revision Bundle. |
5
|
|
|
* |
6
|
|
|
* Copyright 2017 Sourcefabric z.u. and contributors. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please see the |
9
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @copyright 2015 Sourcefabric z.ú |
12
|
|
|
* @license http://www.superdesk.org/license |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace SWP\Bundle\RevisionBundle\DependencyInjection; |
16
|
|
|
|
17
|
|
|
use SWP\Bundle\CoreBundle\Model\Revision; |
18
|
|
|
use SWP\Bundle\RevisionBundle\Model\RevisionLog; |
19
|
|
|
use SWP\Bundle\RevisionBundle\Repository\RevisionRepository; |
20
|
|
|
use SWP\Bundle\StorageBundle\Doctrine\ORM\EntityRepository; |
21
|
|
|
use SWP\Component\Revision\Model\RevisionInterface; |
22
|
|
|
use SWP\Component\Revision\Model\RevisionLogInterface; |
23
|
|
|
use SWP\Component\Storage\Factory\Factory; |
24
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
25
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* This is the class that validates and merges configuration from your app/config files. |
29
|
|
|
* |
30
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html} |
31
|
|
|
*/ |
32
|
|
View Code Duplication |
class Configuration implements ConfigurationInterface |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
|
|
public function getConfigTreeBuilder() |
38
|
|
|
{ |
39
|
|
|
$treeBuilder = new TreeBuilder(); |
40
|
|
|
$treeBuilder->root('swp_revision') |
41
|
|
|
->children() |
42
|
|
|
->arrayNode('persistence') |
43
|
|
|
->addDefaultsIfNotSet() |
44
|
|
|
->children() |
45
|
|
|
->arrayNode('orm') |
46
|
|
|
->addDefaultsIfNotSet() |
47
|
|
|
->canBeEnabled() |
48
|
|
|
->children() |
49
|
|
|
->arrayNode('classes') |
50
|
|
|
->addDefaultsIfNotSet() |
51
|
|
|
->children() |
52
|
|
|
->arrayNode('revision') |
53
|
|
|
->addDefaultsIfNotSet() |
54
|
|
|
->children() |
55
|
|
|
->scalarNode('model')->cannotBeEmpty()->defaultValue(Revision::class)->end() |
56
|
|
|
->scalarNode('interface')->defaultValue(RevisionInterface::class)->end() |
57
|
|
|
->scalarNode('repository')->defaultValue(RevisionRepository::class)->end() |
58
|
|
|
->scalarNode('factory')->defaultValue(Factory::class)->end() |
59
|
|
|
->scalarNode('object_manager_name')->defaultValue(null)->end() |
60
|
|
|
->end() |
61
|
|
|
->end() |
62
|
|
|
->arrayNode('revision_log') |
63
|
|
|
->addDefaultsIfNotSet() |
64
|
|
|
->children() |
65
|
|
|
->scalarNode('model')->cannotBeEmpty()->defaultValue(RevisionLog::class)->end() |
66
|
|
|
->scalarNode('interface')->defaultValue(RevisionLogInterface::class)->end() |
67
|
|
|
->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
68
|
|
|
->scalarNode('factory')->defaultValue(Factory::class)->end() |
69
|
|
|
->scalarNode('object_manager_name')->defaultValue(null)->end() |
70
|
|
|
->end() |
71
|
|
|
->end() |
72
|
|
|
->end() // classes |
73
|
|
|
->end() |
74
|
|
|
->end() |
75
|
|
|
->end() |
76
|
|
|
->end() |
77
|
|
|
->end() |
78
|
|
|
; |
79
|
|
|
|
80
|
|
|
return $treeBuilder; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.