Issues (3641)

Command/SendOrderStatusChangedMessagePlugin.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\Oms\Communication\Plugin\Oms\Command;
9
10
use Orm\Zed\Sales\Persistence\SpySalesOrder;
11
use Spryker\Zed\Kernel\Communication\AbstractPlugin;
12
use Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject;
13
use Spryker\Zed\Oms\Dependency\Plugin\Command\CommandByOrderInterface;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Spryker\Zed\Oms\Communic...CommandByOrderInterface. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
14
15
/**
16
 * @method \Spryker\Zed\Oms\Business\OmsFacadeInterface getFacade()
17
 * @method \Spryker\Zed\Oms\Communication\OmsCommunicationFactory getFactory()
18
 * @method \Spryker\Zed\Oms\OmsConfig getConfig()
19
 * @method \Spryker\Zed\Oms\Persistence\OmsQueryContainerInterface getQueryContainer()
20
 */
21
class SendOrderStatusChangedMessagePlugin extends AbstractPlugin implements CommandByOrderInterface
22
{
23
    /**
24
     * {@inheritDoc}
25
     * - Sends OrderStatusChanged message to the message broker `orders` channel.
26
     *
27
     * @api
28
     *
29
     * @param array<\Orm\Zed\Sales\Persistence\SpySalesOrderItem> $orderItems
30
     * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity
31
     * @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data
32
     *
33
     * @return array
34
     */
35
    public function run(array $orderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data): array
36
    {
37
        $this->getFacade()->sendOrderStatusChangedMessage($orderEntity->getIdSalesOrder());
38
39
        return [];
40
    }
41
}
42