Completed
Push — 1.10 ( 3bcec0...1a0641 )
by
unknown
08:47
created

AbstractInitialProcessor::getSyncedTo()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 10

Duplication

Lines 7
Ratio 43.75 %

Importance

Changes 0
Metric Value
dl 7
loc 16
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 10
nc 3
nop 2
1
<?php
2
3
namespace OroCRM\Bundle\MagentoBundle\Provider;
4
5
use Doctrine\ORM\EntityManager;
6
7
use Oro\Bundle\IntegrationBundle\Entity\Channel as Integration;
8
use Oro\Bundle\IntegrationBundle\Provider\ConnectorInterface;
9
10
use OroCRM\Bundle\MagentoBundle\Provider\Connector\DictionaryConnectorInterface;
11
12
abstract class AbstractInitialProcessor extends MagentoSyncProcessor
13
{
14
    const INITIAL_SYNC_START_DATE = 'initialSyncStartDate';
15
    const CONNECTORS_INITIAL_SYNCED_TO = 'connectorsInitialSyncedTo';
16
17
    /**
18
     * @param object $entity
19
     */
20
    protected function saveEntity($entity)
21
    {
22
        /** @var EntityManager $em */
23
        $em = $this->doctrineRegistry->getManager();
24
        $em->persist($entity);
25
        $em->flush($entity);
26
    }
27
28
    /**
29
     * @param Integration $integration
30
     */
31
    protected function processDictionaryConnectors(Integration $integration)
32
    {
33
        /** @var ConnectorInterface[] $dictionaryConnectors */
34
        $dictionaryConnectors = $this->registry->getRegisteredConnectorsTypes(
35
            ChannelType::TYPE,
36
            function (ConnectorInterface $connector) {
37
                return $connector instanceof DictionaryConnectorInterface;
38
            }
39
        )->toArray();
40
41
        foreach ($dictionaryConnectors as $connector) {
42
            $this->processIntegrationConnector($integration, $connector);
43
        }
44
    }
45
}
46