|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Psi\Bundle\ContentType\DependencyInjection\Storage; |
|
4
|
|
|
|
|
5
|
|
|
use Psi\Bundle\ContentType\DependencyInjection\LoaderInterface; |
|
6
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeBuilder; |
|
7
|
|
|
use Symfony\Component\Config\FileLocator; |
|
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
9
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
|
10
|
|
|
|
|
11
|
|
|
class PhpcrOdmLoader implements LoaderInterface |
|
12
|
|
|
{ |
|
13
|
|
|
private $container; |
|
14
|
|
|
|
|
15
|
|
|
public function __construct(ContainerBuilder $container) |
|
16
|
|
|
{ |
|
17
|
|
|
$this->container = $container; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* {@inheritdoc} |
|
22
|
|
|
*/ |
|
23
|
|
|
public function configure(NodeBuilder $node) |
|
24
|
|
|
{ |
|
25
|
|
|
$node |
|
26
|
|
|
->arrayNode('phpcr') |
|
27
|
|
|
->addDefaultsIfNotSet() |
|
28
|
|
|
->children() |
|
29
|
|
|
->scalarNode('namespace_prefix') |
|
30
|
|
|
->info('Prefix to use for content-type-managed documents') |
|
31
|
|
|
->defaultValue('cmfct') |
|
32
|
|
|
->end() |
|
33
|
|
|
->scalarNode('namespace_uri') |
|
34
|
|
|
->defaultValue('https://github.com/psiphp/content-type') |
|
35
|
|
|
->end() |
|
36
|
|
|
->end() |
|
37
|
|
|
->end() |
|
38
|
|
|
->arrayNode('mapped_namespaces') |
|
39
|
|
|
->info('Namespaces which should be mapped') |
|
40
|
|
|
->prototype('scalar')->end() |
|
41
|
|
|
->end(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* {@inheritdoc} |
|
46
|
|
|
*/ |
|
47
|
|
|
public function load(array $config) |
|
48
|
|
|
{ |
|
49
|
|
|
$prefix = 'psi_content_type.storage.doctrine_phpcr_odm.'; |
|
50
|
|
|
$this->container->setParameter($prefix . 'namespace_prefix', $config['phpcr']['namespace_prefix']); |
|
51
|
|
|
$this->container->setParameter($prefix . 'namespace_uri', ''); |
|
52
|
|
|
$this->container->setParameter($prefix . 'mapped_namespaces', $config['mapped_namespaces']); |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
$loader = new Loader\XmlFileLoader($this->container, new FileLocator(__DIR__.'/../../Resources/config')); |
|
56
|
|
|
$loader->load('doctrine/phpcr-odm.xml'); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|