<?php

declare(strict_types=1);

/*
 * This file is part of the Ferienpass package.
 *
 * (c) Richard Henkenjohann <richard@ferienpass.online>
 *
 * For more information visit the project website <https://ferienpass.online>
 * or the documentation under <https://docs.ferienpass.online>.
 */

namespace Ferienpass\CoreBundle\Message;

use Ferienpass\CoreBundle\Entity\Attendance;

class CommitAttendances implements LoggableMessageInterface
{
    /**
     * @param array<string> $attendanceIds
     */
    public function __construct(private readonly string $editionId, private readonly array $attendanceIds, private readonly bool $sendDecisions, private readonly ?string $host = null)
    {
    }

    public function getEditionId(): string
    {
        return $this->editionId;
    }

    /**
     * The HTTP host of the request that triggered the commit, captured so the
     * (CLI / worker) handler can scope its cache BANs to the right tenant —
     * the worker has no request, so {@see \Symfony\Component\Routing\RequestContext}
     * carries no host of its own.
     */
    public function getHost(): ?string
    {
        return $this->host;
    }

    public function getAttendanceIds(): array
    {
        return $this->attendanceIds;
    }

    public function shouldSendDecisions(): bool
    {
        return $this->sendDecisions;
    }

    public function getRelated(): array
    {
        return [
            Attendance::class => $this->attendanceIds,
        ];
    }
}
