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
declare(strict_types=1);
9
10
namespace SprykerFeature\Zed\SelfServicePortal\Communication\Plugin\Publisher\SspAsset\Search;
11
12
use Spryker\Zed\Kernel\Communication\AbstractPlugin;
13
use Spryker\Zed\PublisherExtension\Dependency\Plugin\PublisherPluginInterface;
14
use SprykerFeature\Shared\SelfServicePortal\SelfServicePortalConfig;
15
16
/**
17
 * @method \SprykerFeature\Zed\SelfServicePortal\SelfServicePortalConfig getConfig()
18
 * @method \SprykerFeature\Zed\SelfServicePortal\Business\SelfServicePortalFacadeInterface getFacade()
19
 * @method \SprykerFeature\Zed\SelfServicePortal\Communication\SelfServicePortalCommunicationFactory getFactory()
20
 * @method \SprykerFeature\Zed\SelfServicePortal\Business\SelfServicePortalBusinessFactory getBusinessFactory()
21
 */
22
class SspAssetWritePublisherPlugin extends AbstractPlugin implements PublisherPluginInterface
23
{
24
    /**
25
     * {@inheritDoc}
26
     * - Publishes SSP asset data by `SpySspAsset` entity events.
27
     * - Retrieves all SSP Assets using IDs from $eventTransfers.
28
     * - Updates entities from `spy_ssp_asset_search` with actual data from obtained SSP Assets.
29
     * - Sends a copy of data to queue based on module config.
30
     *
31
     * @api
32
     *
33
     * @param array<\Generated\Shared\Transfer\EventEntityTransfer> $eventEntityTransfers
34
     * @param string $eventName
35
     *
36
     * @return void
37
     */
38
    public function handleBulk(array $eventEntityTransfers, $eventName): void
39
    {
40
        $this->getBusinessFactory()->createSspAssetSearchWriter()->writeCollectionBySspAssetEvents($eventEntityTransfers);
41
    }
42
43
    /**
44
     * {@inheritDoc}
45
     *
46
     * @api
47
     *
48
     * @return array<string>
49
     */
50
    public function getSubscribedEvents(): array
51
    {
52
        return [
53
            SelfServicePortalConfig::ENTITY_SPY_SSP_ASSET_CREATE,
54
            SelfServicePortalConfig::ENTITY_SPY_SSP_ASSET_UPDATE,
55
            SelfServicePortalConfig::SSP_ASSET_PUBLISH,
56
        ];
57
    }
58
}
59