Completed
Pull Request — master (#1)
by Rafał
03:36 queued 01:22
created

CmfCandidatesConfigurator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A configure() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher MultiTenancy Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
namespace SWP\MultiTenancyBundle\Doctrine\PHPCR;
15
16
use SWP\Component\MultiTenancy\PathBuilder\TenantAwarePathBuilderInterface;
17
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\PrefixCandidates;
18
19
/**
20
 * CMF Candidates Configurator allows to use TenantAwarePathBuilder to configure
21
 * Symfony CMF PrefixCandidates service after its instantiation.
22
 */
23
class CmfCandidatesConfigurator
24
{
25
    /**
26
     * @var TenantAwarePathBuilderInterface
27
     */
28
    private $pathBuilder;
29
30
    /**
31
     * @var array
32
     */
33
    private $routeBasePaths;
34
35
    /**
36
     * Construct.
37
     *
38
     * @param TenantAwarePathBuilderInterface $pathBuilder    Tenant aware path builder
39
     * @param array                           $routeBasePaths A set of paths where routes are located in the PHPCR tree
40
     */
41
    public function __construct(TenantAwarePathBuilderInterface $pathBuilder, array $routeBasePaths)
42
    {
43
        $this->pathBuilder = $pathBuilder;
44
        $this->routeBasePaths = $routeBasePaths;
45
    }
46
47
    /**
48
     * Configures CMF PrefixCandidates service
49
     * by setting its prefixes to tenant aware paths.
50
     *
51
     * @param PrefixCandidates $candidates PrefixCandidates object
52
     */
53
    public function configure(PrefixCandidates $candidates)
54
    {
55
        $candidates->setPrefixes((array) $this->pathBuilder->build($this->routeBasePaths));
56
    }
57
}
58