Completed
Push — master ( d01ad3...6b97e6 )
by Paweł
21s queued 10s
created

TenantThemesPathsProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getTenantThemesPaths() 0 16 4
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Web Publisher Core Bundle.
7
 *
8
 * Copyright 2019 Sourcefabric z.u. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2019 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Bundle\CoreBundle\Theme\Provider;
18
19
use SWP\Component\MultiTenancy\Context\TenantContextInterface;
20
use SWP\Component\MultiTenancy\Exception\TenantNotFoundException;
21
22
final class TenantThemesPathsProvider implements TenantThemesPathsProviderInterface
23
{
24
    private $tenantContext;
25
26
    public function __construct(TenantContextInterface $tenantContext)
27
    {
28
        $this->tenantContext = $tenantContext;
29
    }
30
31
    public function getTenantThemesPaths(array $paths): array
32
    {
33
        try {
34
            $tenant = $this->tenantContext->getTenant();
35
        } catch (TenantNotFoundException $e) {
36
            $tenant = null;
37
        }
38
39
        if (null !== $tenant) {
40
            foreach ($paths as $key => $path) {
41
                $paths[$key] = $path.DIRECTORY_SEPARATOR.$tenant->getCode();
42
            }
43
        }
44
45
        return $paths;
46
    }
47
}
48