NodeTypeRegistrator::registerNodeTypes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Psi\Bridge\ContentType\Doctrine\PhpcrOdm;
6
7
use PHPCR\SessionInterface;
8
9
/**
10
 * Encapsulates the logic for registering system node types.
11
 */
12
final class NodeTypeRegistrator
13
{
14
    private $encoder;
15
16
    public function __construct(PropertyEncoder $encoder)
17
    {
18
        $this->encoder = $encoder;
19
    }
20
21
    /**
22
     * Register the content-type node types with the given PHPCR session.
23
     */
24
    public function registerNodeTypes(SessionInterface $session)
25
    {
26
        $cnd = sprintf(
27
            '<%s=\'https://github.com/symfony-cmf/content-type\'>',
28
            $this->encoder->getPrefix(),
29
            $this->encoder->getUri()
30
        );
31
32
        $nodeTypeManager = $session->getWorkspace()->getNodeTypeManager();
33
        $nodeTypeManager->registerNodeTypesCnd($cnd, true);
34
    }
35
}
36