<?php

namespace KupShop\ReturnsBundle\Page;

use KupShop\ContentBundle\Entity\Placeholder;

class CPReturnDeliveryPage extends AbstractReturnDeliveryPage
{
    protected static $name = 'Vratka - doprava: Česká pošta';
    protected static $type = 'RETURN_DELIVERY_CP';
    protected $returnDeliveryClass = 'CPReturnDelivery';

    public function getUrl(): string
    {
        return path('kupshop_returns_returndeliverypage_returndeliveryinfo', ['returnDeliveryCode' => 'cp']);
    }

    public function getPlaceholders(): array
    {
        $placeholders = parent::getPlaceholders();

        if (findModule(\Modules::RETURNS, \Modules::SUB_CP_AUTH_CODES)) {
            $placeholders[] = new Placeholder('PACKAGE_LABEL', 'Autorizační kód Odvozu zboží', function () {
                $return = $this->getReturn();

                return $return ? $this->returnsUtil->getAuthCode($return->getId()) : '-';
            });
        }

        return $placeholders;
    }
}
