<?php
declare (strict_types=1);

namespace App\Entity\Organization;

use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Put;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiFilter;
use App\Repository\Organization\SettingsRepository;

//use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Caractéristiques d'une Organization (produits, options...etc)
 */
#[ApiResource]
//#[Auditable]
#[ORM\Entity(repositoryClass: SettingsRepository::class)]
class Settings
{
    #[ORM\Id]
    #[ORM\Column]
    #[ORM\GeneratedValue]
    private ?int $id = null;

    #[ORM\OneToOne(inversedBy: 'settings', cascade: ['persist', 'remove'])]
    #[ORM\JoinColumn(nullable: false)]
    private ?Organization $organization = null;

    #[ORM\Column(length: 255)]
    #[Assert\Choice(callback: ['\\App\\Enum\\Organization\\SettingsProductEnum', 'toArray'], message: 'invalid-product')]
    private string $product;

    /** @var mixed[]|null  */
    #[ORM\Column(type: 'json', length: 4294967295, nullable: true)]
    private ?array $modules = [];

    /** @var mixed[]|null  */
    #[ORM\Column(type: 'json', length: 4294967295, nullable: true)]
    private ?array $actions = [];

    #[ORM\Column(length: 255, options: ['default' => 'FRANCE'])]
    private string $country;

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

    public function getOrganization(): ?Organization
    {
        return $this->organization;
    }

    public function setOrganization(Organization $organization): self
    {
        $this->organization = $organization;
        return $this;
    }

    public function getProduct(): string
    {
        return $this->product;
    }

    public function setProduct(string $product): self
    {
        $this->product = $product;
        return $this;
    }

    /**
     * @return mixed[]|null
     */
    public function getModules(): ?array
    {
        return $this->modules;
    }

    /**
     * @param mixed[]|null $modules
     * @return $this
     */
    public function setModules(?array $modules): self
    {
        $this->modules = $modules;
        return $this;
    }

    /**
     * @return mixed[]|null
     */
    public function getActions(): ?array
    {
        return $this->actions;
    }

    /**
     * @param mixed[]|null $actions
     * @return $this
     */
    public function setActions(?array $actions): self
    {
        $this->actions = $actions;
        return $this;
    }

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

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