Issues (3641)

Listener/AssetStoreStorageUnpublishListener.php (1 issue)

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 Spryker\Zed\AssetStorage\Communication\Plugin\Event\Listener;
9
10
use Spryker\Shared\Kernel\Transfer\TransferInterface;
11
use Spryker\Zed\AssetStorage\AssetStorageConfig;
12
use Spryker\Zed\AssetStorage\Communication\Exception\NoForeignKeyException;
13
use Spryker\Zed\Event\Dependency\Plugin\EventHandlerInterface;
14
use Spryker\Zed\Kernel\Communication\AbstractPlugin;
15
16
/**
17
 * @deprecated Use {@link \Spryker\Zed\AssetStorage\Communication\Plugin\Publisher\Asset\AssetDeletePublisherPlugin} instead.
18
 *
19
 * @method \Spryker\Zed\AssetStorage\Business\AssetStorageFacadeInterface getFacade()
20
 * @method \Spryker\Zed\AssetStorage\AssetStorageConfig getConfig()
21
 * @method \Spryker\Zed\AssetStorage\Communication\AssetStorageCommunicationFactory getFactory()
22
 */
23
class AssetStoreStorageUnpublishListener extends AbstractPlugin implements EventHandlerInterface
24
{
25
    /**
26
     * @param \Generated\Shared\Transfer\EventEntityTransfer $eventEntityTransfer
27
     * @param string $eventName
28
     *
29
     * @throws \Spryker\Zed\AssetStorage\Communication\Exception\NoForeignKeyException
30
     *
31
     * @return void
32
     */
33
    public function handle(TransferInterface $eventEntityTransfer, $eventName)
34
    {
35
        $foreignKeys = $eventEntityTransfer->getForeignKeys();
0 ignored issues
show
The method getForeignKeys() does not exist on Spryker\Shared\Kernel\Transfer\TransferInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        /** @scrutinizer ignore-call */ 
36
        $foreignKeys = $eventEntityTransfer->getForeignKeys();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
37
        if (!isset($foreignKeys[AssetStorageConfig::COL_FK_STORE])) {
38
            throw new NoForeignKeyException(AssetStorageConfig::COL_FK_STORE);
39
        }
40
        if (!isset($foreignKeys[AssetStorageConfig::COL_FK_ASSET])) {
41
            throw new NoForeignKeyException(AssetStorageConfig::COL_FK_ASSET);
42
        }
43
44
        $idStore = $foreignKeys[AssetStorageConfig::COL_FK_STORE];
45
        $idAsset = $foreignKeys[AssetStorageConfig::COL_FK_ASSET];
46
47
        $this->getFacade()->unpublishStoreRelation($idAsset, $idStore);
48
    }
49
}
50