Completed
Push — 1.9 ( d8eb28...5c3e2e )
by
unknown
61:52 queued 29s
created

findEntityByIdentityValues()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
namespace OroCRM\Bundle\MagentoBundle\ImportExport\Strategy;
4
5
use Symfony\Component\PropertyAccess\PropertyAccess;
6
use Symfony\Component\PropertyAccess\PropertyAccessor;
7
8
use Oro\Bundle\ImportExportBundle\Strategy\Import\ConfigurableAddOrReplaceStrategy;
9
10
class DefaultMagentoImportStrategy extends ConfigurableAddOrReplaceStrategy
11
{
12
    /** @var PropertyAccessor */
13
    protected $propertyAccessor;
14
15
    /**
16
     * {@inheritdoc}
17
     */
18
    protected function updateContextCounters($entity)
19
    {
20
        // increment context counter
21
        $identifier = $this->databaseHelper->getIdentifier($entity);
22
        if ($identifier) {
23
            $this->context->incrementUpdateCount();
24
        } else {
25
            $this->context->incrementAddCount();
26
        }
27
28
        return $entity;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function findEntityByIdentityValues($entityName, array $identityValues)
35
    {
36
        if (is_a($entityName, 'OroCRM\Bundle\MagentoBundle\Entity\IntegrationAwareInterface', true)) {
37
            $identityValues['channel'] = $this->context->getOption('channel');
38
        }
39
40
        return parent::findEntityByIdentityValues($entityName, $identityValues);
41
    }
42
43
    /**
44
     * @return PropertyAccessor
45
     */
46
    protected function getPropertyAccessor()
47
    {
48
        if (!$this->propertyAccessor) {
49
            $this->propertyAccessor = PropertyAccess::createPropertyAccessor();
50
        }
51
        return $this->propertyAccessor;
52
    }
53
}
54