callback w commandzie

inal class UpdateUnpaidOrdersMessage implements CommandMessageInterface
{
    private int $fetchInterval;
    private int $websiteId;
    private int $limit;
    private ArrayCollection $responseMessages;
    private $onProcessOrder;

    public function __construct(
        int $fetchInterval,
        int $websiteId,
        int $limit,
        $onProcessOrder = null
    ) {
        $this->fetchInterval = $fetchInterval;
        $this->websiteId = $websiteId;
        $this->limit = $limit;
        $this->onProcessOrder = $onProcessOrder;
        $this->responseMessages = new ArrayCollection();
    }
}
        $message = new UpdateUnpaidOrdersMessageV2(
            $fetchInterval,
            $websiteId,
            $limit,
            function (array $ceneoOrder) use ($output, &$index) {
                $timestamp = (int) str_replace(['/Date(', ')'], ['', ''], $ceneoOrder['CreatedDate']);
                $createdDate = new DateTime();
                $createdDate->setTimestamp((int) ($timestamp / 1000));

                $output->writeln("Index: {$index}");
                $output->writeln("Id: {$ceneoOrder['Id']}");
                $output->writeln("ShopOrderId: {$ceneoOrder['ShopOrderId']}");
                $output->writeln("DisplayedOrderId: {$ceneoOrder['DisplayedOrderId']}");
                $output->writeln("OrderStateId: {$ceneoOrder['OrderStateId']}");
                $output->writeln("PaymentMethodId: {$ceneoOrder['PaymentMethodId']}");
                $output->writeln("PaymentTypeId: {$ceneoOrder['PaymentTypeId']}");
                $output->writeln("OrderValue: {$ceneoOrder['OrderValue']}");
                $output->writeln("CreatedDate: {$ceneoOrder['CreatedDate']} - {$createdDate->format('Y-m-d H:i:s')}");
                $output->writeln('------------------------------');
                $index++;
            }
        );
    private function onProcessOrder(UpdateUnpaidOrdersMessage $message, array $ceneoOrder): void
    {
        $onProcessOrder = $message->onProcessOrder();
        if (!is_callable($onProcessOrder)) {
            return;
        }

        $onProcessOrder($ceneoOrder);
    }

 

Komentarze wyłączone