<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Terminy\Listeners\Udalost;

use Seka\Portal\Modul\Terminy\Entities\Dtos\UdalostDTO;
use Seka\Portal\Modul\Terminy\Events\Udalost\ZverejnenaUdalostBolaNezverejnena;

/**
 * Class NezverejnitZverejnenuUdalostiVKalendari
 *
 * @package Seka\Portal\Modul\Terminy\Listeners\Udalost
 */
final class NezverejnitZverejnenuUdalostiVKalendari extends UdalostVKalendari
{
    /**
     * @param \Seka\Portal\Modul\Terminy\Events\Udalost\ZverejnenaUdalostBolaNezverejnena $event
     *
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     * @throws \Spatie\LaravelData\Exceptions\CannotCreateData
     */
    public function handle(ZverejnenaUdalostBolaNezverejnena $event): void
    {
        $udalost = UdalostDTO::from($event->udalost);

        $this->calendarService->deleteEvent($udalost);
    }
}
