<?php

namespace Shop\HanibalBundle\Resources\script;

use KupShop\AdminBundle\Util\Script\Script;
use KupShop\PohodaBundle\Messenger\OrderMessage;

class PohodaHandleOrderMessage extends Script
{
    use \DatabaseCommunication;

    protected static $name = '[Pohoda] Zavolat handle na orderMessage pro objednávku';
    protected static $defaultParameters = [
        'bacha, nefunguje dedeni z shopu, protoze to neni servisa!!' => true,
        'id_order' => null,
    ];

    protected function run(array $arguments)
    {
        if (empty($arguments['id_order'])) {
            $this->log('Nezadáno id objednávky...');
        }
        $order = new \Order($arguments['id_order']);
        $order->createFromDB($arguments['id_order']);

        $orderMessage = new OrderMessage();
        $orderMessage->setIdOrder($order->id);
        $orderMessage->handle();

        $this->log('Hotovo');
    }
}

return PohodaHandleOrderMessage::class;
