Completed
Push — master ( 7a069b...4da1f4 )
by Paweł
11s
created

TenantAwareMetaKeyGenerator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Core Bundle.
5
 *
6
 * Copyright 2017 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 2017 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\CoreBundle\Twig\Cache\KeyGenerator;
16
17
use SWP\Bundle\ContentBundle\KeyGenerator\MetaKeyGenerator;
18
use SWP\Component\MultiTenancy\Context\TenantContextInterface;
19
20
/**
21
 * Key generator for meta objects.
22
 */
23 View Code Duplication
class TenantAwareMetaKeyGenerator extends MetaKeyGenerator
1 ignored issue
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
{
25
    /**
26
     * @var TenantContextInterface
27
     */
28
    protected $tenantContext;
29
30
    /**
31
     * MetaKeyGenerator constructor.
32
     *
33
     * @param TenantContextInterface $tenantContext
34
     */
35
    public function __construct(TenantContextInterface $tenantContext)
36
    {
37
        $this->tenantContext = $tenantContext;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function generateKey($meta)
44
    {
45
        $tenantCode = $this->tenantContext->getTenant()->getCode();
46
47
        return $tenantCode.'_'.parent::generateKey($meta);
48
    }
49
}
50