1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the Content class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Parser; |
10
|
|
|
|
11
|
|
|
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\AbstractParser; |
12
|
|
|
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface; |
13
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeBuilder; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Configuration parser handling content related config. |
17
|
|
|
*/ |
18
|
|
|
class Content extends AbstractParser |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Adds semantic configuration definition. |
22
|
|
|
* |
23
|
|
|
* @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system.<siteaccess> |
24
|
|
|
*/ |
25
|
|
|
public function addSemanticConfig(NodeBuilder $nodeBuilder) |
26
|
|
|
{ |
27
|
|
|
$nodeBuilder |
28
|
|
|
->arrayNode('content') |
29
|
|
|
->info('Content related configuration') |
30
|
|
|
->children() |
31
|
|
|
->booleanNode('view_cache')->end() |
32
|
|
|
->booleanNode('ttl_cache')->end() |
33
|
|
|
->scalarNode('default_ttl')->info('Default value for TTL cache, in seconds')->end() |
34
|
|
|
->arrayNode('tree_root') |
35
|
|
|
->canBeUnset() |
36
|
|
|
->children() |
37
|
|
|
->integerNode('location_id') |
38
|
|
|
->info("Root locationId for routing and link generation.\nUseful for multisite apps with one repository.") |
39
|
|
|
->isRequired() |
40
|
|
|
->end() |
41
|
|
|
->arrayNode('excluded_uri_prefixes') |
42
|
|
|
->info("URI prefixes that are allowed to be outside the content tree\n(useful for content sharing between multiple sites).\nPrefixes are not case sensitive") |
43
|
|
|
->example(array('/media/images', '/products')) |
44
|
|
|
->prototype('scalar')->end() |
45
|
|
|
->end() |
46
|
|
|
->end() |
47
|
|
|
->end() |
48
|
|
|
->end() |
49
|
|
|
->end(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer) |
53
|
|
|
{ |
54
|
|
|
if (!empty($scopeSettings['content'])) { |
55
|
|
|
if (isset($scopeSettings['content']['view_cache'])) { |
56
|
|
|
$contextualizer->setContextualParameter('content.view_cache', $currentScope, $scopeSettings['content']['view_cache']); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
if (isset($scopeSettings['content']['ttl_cache'])) { |
60
|
|
|
$contextualizer->setContextualParameter('content.ttl_cache', $currentScope, $scopeSettings['content']['ttl_cache']); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
if (isset($scopeSettings['content']['default_ttl'])) { |
64
|
|
|
$contextualizer->setContextualParameter('content.default_ttl', $currentScope, $scopeSettings['content']['default_ttl']); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
if (isset($scopeSettings['content']['tree_root'])) { |
68
|
|
|
$contextualizer->setContextualParameter( |
69
|
|
|
'content.tree_root.location_id', |
70
|
|
|
$currentScope, |
71
|
|
|
$scopeSettings['content']['tree_root']['location_id'] |
72
|
|
|
); |
73
|
|
|
if (isset($scopeSettings['content']['tree_root']['excluded_uri_prefixes'])) { |
74
|
|
|
$contextualizer->setContextualParameter( |
75
|
|
|
'content.tree_root.excluded_uri_prefixes', |
76
|
|
|
$currentScope, |
77
|
|
|
$scopeSettings['content']['tree_root']['excluded_uri_prefixes'] |
78
|
|
|
); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|