<?php

namespace External\LeaflyBundle\EventListener;

use KupShop\OrderingBundle\Event\OrderDeliveryEvent;
use KupShop\OrderingBundle\Util\Order\OrderUtil;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class OrderEventListener implements EventSubscriberInterface
{
    /**
     * @var OrderUtil
     */
    private $orderUtil;

    public function __construct(OrderUtil $orderUtil)
    {
        $this->orderUtil = $orderUtil;
    }

    public static function getSubscribedEvents()
    {
        return [
            OrderDeliveryEvent::class => [
                ['orderDelivered', 200],
            ],
        ];
    }

    public function orderDelivered(OrderDeliveryEvent $event)
    {
        $this->orderUtil->addFlag($event->getOrder(), 'SDE');
    }
}
