|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Superdesk Web Publisher Output Channel Bundle. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright 2018 Sourcefabric z.ú. and contributors. |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please see the |
|
11
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
|
12
|
|
|
* |
|
13
|
|
|
* @copyright 2018 Sourcefabric z.ú |
|
14
|
|
|
* @license http://www.superdesk.org/license |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace SWP\Bundle\OutputChannelBundle\DependencyInjection; |
|
18
|
|
|
|
|
19
|
|
|
use SWP\Bundle\StorageBundle\Doctrine\ORM\EntityRepository; |
|
20
|
|
|
use SWP\Component\OutputChannel\Model\ExternalArticle; |
|
21
|
|
|
use SWP\Component\OutputChannel\Model\ExternalArticleInterface; |
|
22
|
|
|
use SWP\Component\OutputChannel\Model\OutputChannel; |
|
23
|
|
|
use SWP\Component\OutputChannel\Model\OutputChannelInterface; |
|
24
|
|
|
use SWP\Component\Storage\Factory\Factory; |
|
25
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
26
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
27
|
|
|
|
|
28
|
|
View Code Duplication |
class Configuration implements ConfigurationInterface |
|
|
|
|
|
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* {@inheritdoc} |
|
32
|
|
|
*/ |
|
33
|
|
|
public function getConfigTreeBuilder() |
|
34
|
|
|
{ |
|
35
|
|
|
$treeBuilder = new TreeBuilder(); |
|
36
|
|
|
$treeBuilder->root('swp_output_channel') |
|
37
|
|
|
->children() |
|
38
|
|
|
->arrayNode('persistence') |
|
39
|
|
|
->addDefaultsIfNotSet() |
|
40
|
|
|
->children() |
|
41
|
|
|
->arrayNode('orm') |
|
42
|
|
|
->addDefaultsIfNotSet() |
|
43
|
|
|
->canBeEnabled() |
|
44
|
|
|
->children() |
|
45
|
|
|
->arrayNode('classes') |
|
46
|
|
|
->addDefaultsIfNotSet() |
|
47
|
|
|
->children() |
|
48
|
|
|
->arrayNode('output_channel') |
|
49
|
|
|
->addDefaultsIfNotSet() |
|
50
|
|
|
->children() |
|
51
|
|
|
->scalarNode('model')->cannotBeEmpty()->defaultValue(OutputChannel::class)->end() |
|
52
|
|
|
->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
|
53
|
|
|
->scalarNode('interface')->defaultValue(OutputChannelInterface::class)->end() |
|
54
|
|
|
->scalarNode('factory')->defaultValue(Factory::class)->end() |
|
55
|
|
|
->scalarNode('object_manager_name')->defaultValue(null)->end() |
|
56
|
|
|
->end() |
|
57
|
|
|
->end() |
|
58
|
|
|
->arrayNode('external_article') |
|
59
|
|
|
->addDefaultsIfNotSet() |
|
60
|
|
|
->children() |
|
61
|
|
|
->scalarNode('model')->cannotBeEmpty()->defaultValue(ExternalArticle::class)->end() |
|
62
|
|
|
->scalarNode('repository')->defaultValue(EntityRepository::class)->end() |
|
63
|
|
|
->scalarNode('interface')->defaultValue(ExternalArticleInterface::class)->end() |
|
64
|
|
|
->scalarNode('factory')->defaultValue(Factory::class)->end() |
|
65
|
|
|
->scalarNode('object_manager_name')->defaultValue(null)->end() |
|
66
|
|
|
->end() |
|
67
|
|
|
->end() |
|
68
|
|
|
->end() |
|
69
|
|
|
->end() |
|
70
|
|
|
->end() |
|
71
|
|
|
->end() |
|
72
|
|
|
->end() |
|
73
|
|
|
->end() |
|
74
|
|
|
->end(); |
|
75
|
|
|
|
|
76
|
|
|
return $treeBuilder; |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
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.