<?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\Entity;

/**
 * Marks an entity as belonging to exactly one {@see Tenant}.
 *
 * Two things key off this interface, and nothing else has to be touched to
 * make an entity tenant-scoped:
 *
 *  - {@see \Ferienpass\CoreBundle\Tenant\TenantFilter} appends `tenant_id = ?`
 *    to every SELECT against the entity while a tenant is active;
 *  - {@see \Ferienpass\CoreBundle\EventListener\TenantPersistListener} stamps
 *    the active tenant onto new rows.
 *
 * Use {@see TenantAwareTrait} for the mapping and the accessors.
 *
 * Only aggregate roots need to implement this — rows that are reachable solely
 * through a tenant-aware parent (an OfferDate, a log entry) are already
 * unreachable across tenants because the parent is filtered.
 */
interface TenantAwareInterface
{
    public function getTenant(): ?Tenant;

    public function setTenant(?Tenant $tenant): void;
}
