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

LifetimeCacheStrategy::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 5
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
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\Strategy;
16
17
use Asm89\Twig\CacheExtension\CacheProviderInterface;
18
use Asm89\Twig\CacheExtension\CacheStrategy\LifetimeCacheStrategy as BaseLifetimeCacheStrategy;
19
use SWP\Component\MultiTenancy\Context\TenantContextInterface;
20
21 View Code Duplication
class LifetimeCacheStrategy extends BaseLifetimeCacheStrategy
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...
22
{
23
    /**
24
     * @var TenantContextInterface
25
     */
26
    protected $tenantContext;
27
28
    /**
29
     * LifetimeCacheStrategy constructor.
30
     *
31
     * @param CacheProviderInterface $cache
32
     * @param TenantContextInterface $tenantContext
33
     */
34
    public function __construct(CacheProviderInterface $cache, TenantContextInterface $tenantContext)
35
    {
36
        $this->tenantContext = $tenantContext;
37
        parent::__construct($cache);
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function generateKey($annotation, $value)
44
    {
45
        $annotation = $this->tenantContext->getTenant()->getCode().'__'.$annotation;
46
47
        return parent::generateKey($annotation, $value);
48
    }
49
}
50