Passed
Push — master ( cacbf1...74b6c9 )
by
unknown
34:14
created

getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerFeature\Zed\SelfServicePortal\Communication\Plugin\Publisher\SspAsset\Search;
9
10
use Spryker\Zed\Kernel\Communication\AbstractPlugin;
11
use Spryker\Zed\PublisherExtension\Dependency\Plugin\PublisherPluginInterface;
12
use SprykerFeature\Shared\SelfServicePortal\SelfServicePortalConfig;
13
14
/**
15
 * @method \SprykerFeature\Zed\SelfServicePortal\Business\SelfServicePortalFacadeInterface getFacade()
16
 * @method \SprykerFeature\Zed\SelfServicePortal\SelfServicePortalConfig getConfig()
17
 * @method \SprykerFeature\Zed\SelfServicePortal\Communication\SelfServicePortalCommunicationFactory getFactory()
18
 * @method \SprykerFeature\Zed\SelfServicePortal\Business\SelfServicePortalBusinessFactory getBusinessFactory()
19
 */
20
class SspAssetToModelWritePublisherPlugin extends AbstractPlugin implements PublisherPluginInterface
21
{
22
    /**
23
     * {@inheritDoc}
24
     * - Publishes SSP asset data by `SpySspAssetToSspModel` entity events.
25
     * - Extracts SSP asset IDs from the `$eventEntityTransfers` created by SSP asset to model entity events.
26
     * - Updates entities from `spy_ssp_asset_search` with actual data from obtained SSP Assets.
27
     * - Sends a copy of data to the queue.
28
     *
29
     * @api
30
     *
31
     * @param list<\Generated\Shared\Transfer\EventEntityTransfer> $eventEntityTransfers
32
     * @param string $eventName
33
     *
34
     * @return void
35
     */
36
    public function handleBulk(array $eventEntityTransfers, $eventName): void
37
    {
38
        $this->getBusinessFactory()->createSspAssetSearchWriter()->writeCollectionBySspAssetToModelEvents($eventEntityTransfers);
39
    }
40
41
    /**
42
     * {@inheritDoc}
43
     *
44
     * @api
45
     *
46
     * @return array<string>
47
     */
48
    public function getSubscribedEvents(): array
49
    {
50
        return [
51
            SelfServicePortalConfig::ENTITY_SPY_SSP_ASSET_TO_MODEL_CREATE,
52
            SelfServicePortalConfig::ENTITY_SPY_SSP_ASSET_TO_MODEL_UPDATE,
53
            SelfServicePortalConfig::ENTITY_SPY_SSP_ASSET_TO_MODEL_DELETE,
54
        ];
55
    }
56
}
57