<?php

/*
 * This file is part of the VitiCore 2.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Shop\Model;

use CpCreation\VitiCore\Behavior\HasTimestamp;
use CpCreation\VitiCore\Behavior\HasTranslatable;
use CpCreation\VitiCore\Behavior\Impl\Timestamp;
use CpCreation\VitiCore\Behavior\Impl\Translatable;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
use Symfony\Component\Validator\Constraints as Assert;

#[ORM\Table(name: 'shop_shop_config_disable_country')]
#[ORM\HasLifecycleCallbacks]
#[ORM\Entity(repositoryClass: 'CpCreation\VitiCore\Shop\Repository\ShopConfigDisableCountryRepository')]
class ShopConfigDisableCountry implements HasTimestamp, HasTranslatable
{
    use Timestamp;
    use Translatable;

    #[Assert\Valid]
    #[ORM\OneToMany(
        targetEntity: Translation\ShopConfigDisableCountryTranslation::class,
        mappedBy: 'translatable',
        cascade: ['all'],
        indexBy: 'locale',
        orphanRemoval: true
    )]
    protected $translations;

    #[ORM\Id]
    #[ORM\Column(type: 'uuid')]
    #[ORM\GeneratedValue(strategy: 'NONE')]
    private UuidInterface $id;

    #[ORM\Column(type: 'string')]
    private string $country;

    #[ORM\ManyToOne(targetEntity: ShopConfig::class, inversedBy: 'disableCountries')]
    private ?ShopConfig $config = null;

    public function __construct()
    {
        $this->id = Uuid::uuid4();
    }

    public function getId(): UuidInterface
    {
        return $this->id;
    }

    public function getCountry(): string
    {
        return $this->country;
    }

    public function setCountry(string $country): void
    {
        $this->country = $country;
    }

    public function getConfig(): ?ShopConfig
    {
        return $this->config;
    }

    public function setConfig(?ShopConfig $config): void
    {
        $this->config = $config;
    }
}
