Completed
Push — inmemory-pool-decoration ( 87319b...a526b7 )
by André
24:59
created

AbstractInMemoryPersistenceHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\Persistence\Cache;
8
9
use eZ\Publish\Core\Persistence\Cache\Adapter\InMemoryClearingProxyAdapter;
10
use eZ\Publish\Core\Persistence\Cache\InMemory\InMemoryCache;
11
use eZ\Publish\SPI\Persistence\Handler as PersistenceHandler;
12
13
/**
14
 * Class AbstractInMemoryHandler.
15
 *
16
 * Abstract handler for use in other SPI Persistence Cache Handlers.
17
 *
18
 * @internal
19
 */
20
abstract class AbstractInMemoryPersistenceHandler extends AbstractInMemoryHandler
21
{
22
    /**
23
     * @var \eZ\Publish\SPI\Persistence\Handler
24
     */
25
    protected $persistenceHandler;
26
27
    /**
28
     * Setups current handler with everything needed.
29
     *
30
     * @param \eZ\Publish\Core\Persistence\Cache\Adapter\InMemoryClearingProxyAdapter $cache
31
     * @param \eZ\Publish\Core\Persistence\Cache\PersistenceLogger $logger
32
     * @param \eZ\Publish\Core\Persistence\Cache\InMemory\InMemoryCache $inMemory
33
     * @param \eZ\Publish\SPI\Persistence\Handler $persistenceHandler
34
     */
35
    public function __construct(
36
        InMemoryClearingProxyAdapter $cache,
37
        PersistenceLogger $logger,
38
        InMemoryCache $inMemory,
39
        PersistenceHandler $persistenceHandler
40
    ) {
41
        parent::__construct($cache, $logger, $inMemory);
42
        $this->persistenceHandler = $persistenceHandler;
43
44
        $this->init();
45
    }
46
47
    /**
48
     * Optional function to initialize handler without having to overload __construct().
49
     */
50
    protected function init(): void
51
    {
52
        // overload to add init logic if needed in handler
53
    }
54
}
55