Completed
Push — ezp25946-migrate_files_to_othe... ( abaa17...7be322 )
by
unknown
41:27 queued 25:33
created

MigrationHandler::logMissingFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the MigrationHandler class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Bundle\EzPublishIOBundle\Migration;
10
11
use eZ\Bundle\EzPublishIOBundle\ApiLoader\HandlerFactory;
12
use Psr\Log\LoggerInterface;
13
14
abstract class MigrationHandler implements MigrationHandlerInterface
15
{
16
    /** @var \eZ\Bundle\EzPublishIOBundle\ApiLoader\HandlerFactory */
17
    protected $metadataHandlerFactory;
18
19
    /** @var \eZ\Bundle\EzPublishIOBundle\ApiLoader\HandlerFactory */
20
    protected $binarydataHandlerFactory;
21
22
    /** @var \Psr\Log\LoggerInterface */
23
    protected $logger;
24
25
    /** @var \eZ\Publish\Core\IO\IOMetadataHandler */
26
    protected $fromMetadataHandler;
27
28
    /** @var \eZ\Publish\Core\IO\IOBinarydataHandler */
29
    protected $fromBinarydataHandler;
30
31
    /** @var \eZ\Publish\Core\IO\IOMetadataHandler */
32
    protected $toMetadataHandler;
33
34
    /** @var \eZ\Publish\Core\IO\IOBinarydataHandler */
35
    protected $toBinarydataHandler;
36
37
    public function __construct(
38
        HandlerFactory $metadataHandlerFactory,
39
        HandlerFactory $binarydataHandlerFactory,
40
        LoggerInterface $logger = null
41
    ) {
42
        $this->metadataHandlerFactory = $metadataHandlerFactory;
43
        $this->binarydataHandlerFactory = $binarydataHandlerFactory;
44
        $this->logger = $logger;
45
    }
46
47
    public function setIODataHandlersByIdentifiers(
48
        $fromMetadataHandlerIdentifier,
49
        $fromBinarydataHandlerIdentifier,
50
        $toMetadataHandlerIdentifier,
51
        $toBinarydataHandlerIdentifier
52
    ) {
53
        $this->fromMetadataHandler = $this->metadataHandlerFactory->getConfiguredHandler($fromMetadataHandlerIdentifier);
54
        $this->fromBinarydataHandler = $this->binarydataHandlerFactory->getConfiguredHandler($fromBinarydataHandlerIdentifier);
55
        $this->toMetadataHandler = $this->metadataHandlerFactory->getConfiguredHandler($toMetadataHandlerIdentifier);
56
        $this->toBinarydataHandler = $this->binarydataHandlerFactory->getConfiguredHandler($toBinarydataHandlerIdentifier);
57
58
        return $this;
59
    }
60
61
    protected function logError($message)
62
    {
63
        if (isset($this->logger)) {
64
            $this->logger->error($message);
65
        }
66
    }
67
68
    protected function logInfo($message)
69
    {
70
        if (isset($this->logger)) {
71
            $this->logger->info($message);
72
        }
73
    }
74
75
    protected function logMissingFile($id)
76
    {
77
         $this->logInfo("File with id $id not found");
78
    }
79
}
80