NodeTypeRegistrator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A registerNodeTypes() 0 11 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