|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Jeroen Fiege <[email protected]> |
|
4
|
|
|
* @author Gerard van Helden <[email protected]> |
|
5
|
|
|
* @copyright Zicht Online <http://zicht.nl> |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace Zicht\Bundle\PageBundle\DependencyInjection; |
|
9
|
|
|
|
|
10
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
11
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
12
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
13
|
|
|
use Symfony\Component\Config\FileLocator; |
|
14
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
15
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Page bundle DI extension |
|
19
|
|
|
*/ |
|
20
|
|
|
class ZichtPageExtension extends Extension |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @{inheritDoc} |
|
24
|
|
|
*/ |
|
25
|
1 |
|
public function load(array $configs, ContainerBuilder $container) |
|
26
|
|
|
{ |
|
27
|
1 |
|
$configuration = new Configuration(); |
|
28
|
1 |
|
$config = $this->processConfiguration($configuration, $configs); |
|
29
|
|
|
|
|
30
|
1 |
|
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
31
|
1 |
|
$loader->load('services.xml'); |
|
32
|
|
|
|
|
33
|
1 |
|
if (true === $config['aliasing']['enabled']) { |
|
34
|
1 |
|
$loader->load('aliasing.xml'); |
|
35
|
|
|
|
|
36
|
1 |
|
if (!empty($config['aliasing']['prefixLanguages'])) { |
|
37
|
|
|
$def = new Definition( |
|
38
|
|
|
'Zicht\Bundle\PageBundle\Aliasing\Strategy\LanguageAwareAliasingStrategy', |
|
39
|
|
|
[ |
|
40
|
|
|
new Reference($config['aliasing']['service']), |
|
41
|
|
|
$config['aliasing']['prefixLanguages'] |
|
42
|
|
|
] |
|
43
|
1 |
|
); |
|
44
|
|
|
} else { |
|
45
|
1 |
|
$def = new Reference($config['aliasing']['service']); |
|
46
|
|
|
} |
|
47
|
|
|
$container |
|
48
|
1 |
|
->getDefinition('zicht_page.page_aliaser') |
|
49
|
1 |
|
->replaceArgument(2, $def) |
|
50
|
1 |
|
->addMethodCall('setConflictingInternalUrlStrategy', [$config['aliasing']['conflictingInternalUrlStrategy']]) |
|
51
|
1 |
|
->addMethodCall('setConflictingPublicUrlStrategy', [$config['aliasing']['conflictingPublicUrlStrategy']]); |
|
52
|
1 |
|
} |
|
53
|
|
|
|
|
54
|
|
|
$container |
|
55
|
1 |
|
->getDefinition('zicht_page.form.type.zicht_content_item_region_type') |
|
56
|
1 |
|
->replaceArgument(0, $config['contentItemClass']) |
|
57
|
1 |
|
->replaceArgument(1, $config['defaultRegions']); |
|
58
|
|
|
|
|
59
|
|
|
$container |
|
60
|
1 |
|
->getDefinition('zicht_page.form.type.zicht_content_item_type_type') |
|
61
|
1 |
|
->replaceArgument(0, $config['contentItemClass']); |
|
62
|
|
|
|
|
63
|
1 |
|
$def = $container->getDefinition('zicht_page.page_manager'); |
|
64
|
1 |
|
$def->replaceArgument(2, $config['pageClass']); |
|
65
|
1 |
|
$def->replaceArgument(3, $config['contentItemClass']); |
|
66
|
|
|
|
|
67
|
1 |
|
$def->addMethodCall('setPageTypes', array($config['types']['page'])); |
|
68
|
1 |
|
$def->addMethodCall('setContentItemTypes', array($config['types']['contentItem'])); |
|
69
|
1 |
|
$container->setParameter('zicht_page.config', $config); |
|
70
|
1 |
|
$container->setParameter('zicht_page.page_types', $config['types']['page']); |
|
71
|
|
|
|
|
72
|
1 |
|
if ($container->hasParameter('twig.form.resources')) { |
|
73
|
1 |
|
$formResources = $container->getParameter('twig.form.resources'); |
|
74
|
1 |
|
$formResources[]= 'ZichtPageBundle::form_theme.html.twig'; |
|
75
|
1 |
|
$container->setParameter('twig.form.resources', $formResources); |
|
76
|
1 |
|
} |
|
77
|
1 |
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|