<?php
declare (strict_types=1);

namespace App\Entity\Public;

use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use App\Filter\Utils\FindInSetFilter;
use App\Repository\Public\FederationStructureRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * Structure telle qu'elle est représentée sur l'iframe de recherche des structures d'une fédération
 *
 * Fichier source de la view : ./sql/schema-extensions/002-view_federation_structures.sql
 */
#[ApiResource(
    operations: [
        new Get(
            uriTemplate: '/public/federation_structures/{id}',
            requirements: ['id' => '\\d+'],
            normalizationContext: ['groups' => ['federation_structure_item_get']]
        ),
        new GetCollection(
            uriTemplate: '/public/federation_structures',
            normalizationContext: ['groups' => ['federation_structure_collection_get']]
        )
    ],
    paginationEnabled: false
)]
#[ORM\Entity(repositoryClass: FederationStructureRepository::class, readOnly: true)]
#[ORM\Table(name: "view_federation_structures")]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['name' => 'partial', 'city' => 'exact'])]
#[ApiFilter(filterClass: NumericFilter::class, properties: ['id', 'parentId'])]
#[ApiFilter(filterClass: FindInSetFilter::class, properties: ['parents'])]
class FederationStructure
{
    #[ORM\Id]
    #[ORM\Column]
    #[Groups(["federation_structure_item_get", "federation_structure_collection_get"])]
    private int $id;

    #[ORM\Column]
    #[Groups(["federation_structure_item_get", "federation_structure_collection_get"])]
    private ?string $name;

    #[ORM\Column(type: 'integer', nullable: true)]
    #[Groups(["federation_structure_item_get", "federation_structure_collection_get"])]
    private ?int $logoId;

    #[ORM\Column]
    #[Groups(["federation_structure_item_get"])]
    private ?string $description;

    #[ORM\Column(type: 'integer')]
    #[Groups(["federation_structure_item_get"])]
    private ?int $imageId;

    #[ORM\Column]
    #[Groups(["federation_structure_item_get", "federation_structure_collection_get"])]
    private ?string $type;

    #[ORM\Column(nullable: true)]
    #[Groups(["federation_structure_item_get", "federation_structure_collection_get"])]
    private ?string $website;

    /** @var mixed[] */
    #[ORM\Column(type: 'json')]
    #[Groups(["federation_structure_item_get", "federation_structure_collection_get"])]
    private array $addresses;

    #[ORM\Column]
    #[Groups(["federation_structure_item_get"])]
    private ?string $phone;

    #[ORM\Column]
    #[Groups(["federation_structure_item_get"])]
    private ?string $mobilePhone;

    #[ORM\Column]
    #[Groups(["federation_structure_item_get"])]
    private ?string $email;

    #[ORM\Column]
    #[Groups(["federation_structure_item_get"])]
    private ?string $facebook;

    #[ORM\Column]
    #[Groups(["federation_structure_item_get"])]
    private ?string $twitter;

    #[ORM\Column]
    #[Groups(["federation_structure_item_get"])]
    private ?string $instagram;

    #[ORM\Column]
    #[Groups(["federation_structure_item_get"])]
    private ?string $youtube;

    /** @var mixed[]|null  */
    #[ORM\Column(type: 'json')]
    #[Groups(["federation_structure_item_get"])]
    private ?array $articles;

    /** @var list<string>|null  */
    #[ORM\Column(type: 'simple_array')]
    #[Groups(["federation_structure_item_get", "federation_structure_collection_get"])]
    private ?array $practices;

    #[ORM\Column(type: 'integer')]
    #[Groups(["federation_structure_item_get", "federation_structure_collection_get"])]
    private ?int $parentId;

    #[ORM\Column]
    #[Groups(["federation_structure_item_get", "federation_structure_collection_get"])]
    private ?string $parentName;

    /** @var list<string>  */
    #[ORM\Column(type: 'simple_array')]
    #[Groups(["federation_structure_item_get", "federation_structure_collection_get"])]
    private array $parents;

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

    /**
     * @param int $id
     * @return FederationStructure
     */
    public function setId(int $id): FederationStructure
    {
        $this->id = $id;
        return $this;
    }

    /**
     * @return string
     */
    public function getName(): string
    {
        return $this->name;
    }

    /**
     * @param string $name
     * @return FederationStructure
     */
    public function setName(string $name): FederationStructure
    {
        $this->name = $name;
        return $this;
    }

    /**
     * @return int|null
     */
    public function getLogoId(): ?int
    {
        return $this->logoId;
    }

    /**
     * @param int|null $logoId
     * @return FederationStructure
     */
    public function setLogoId(?int $logoId): FederationStructure
    {
        $this->logoId = $logoId;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getDescription(): ?string
    {
        return $this->description;
    }

    /**
     * @param string|null $description
     * @return FederationStructure
     */
    public function setDescription(?string $description): FederationStructure
    {
        $this->description = $description;
        return $this;
    }

    /**
     * @return int|null
     */
    public function getImageId(): ?int
    {
        return $this->imageId;
    }

    /**
     * @param int|null $imageId
     * @return FederationStructure
     */
    public function setImageId(?int $imageId): FederationStructure
    {
        $this->imageId = $imageId;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getType(): ?string
    {
        return $this->type;
    }

    /**
     * @param string|null $type
     * @return FederationStructure
     */
    public function setType(?string $type): FederationStructure
    {
        $this->type = $type;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getWebsite(): ?string
    {
        return $this->website;
    }

    /**
     * @param string|null $website
     * @return FederationStructure
     */
    public function setWebsite(?string $website): FederationStructure
    {
        $this->website = $website;
        return $this;
    }

    /**
     * @return mixed[]
     */
    public function getAddresses(): array
    {
        return $this->addresses;
    }

    /**
     * @param mixed[] $addresses
     * @return FederationStructure
     */
    public function setAddresses(array $addresses): FederationStructure
    {
        $this->addresses = $addresses;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getPhone(): ?string
    {
        return $this->phone;
    }

    /**
     * @param string|null $phone
     * @return FederationStructure
     */
    public function setPhone(?string $phone): FederationStructure
    {
        $this->phone = $phone;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getMobilePhone(): ?string
    {
        return $this->mobilePhone;
    }

    /**
     * @param string|null $mobilePhone
     * @return FederationStructure
     */
    public function setMobilePhone(?string $mobilePhone): FederationStructure
    {
        $this->mobilePhone = $mobilePhone;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getEmail(): ?string
    {
        return $this->email;
    }

    /**
     * @param string|null $email
     */
    public function setEmail(?string $email): self
    {
        $this->email = $email;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getFacebook(): ?string
    {
        return $this->facebook;
    }

    /**
     * @param string|null $facebook
     */
    public function setFacebook(?string $facebook): self
    {
        $this->facebook = $facebook;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getTwitter(): ?string
    {
        return $this->twitter;
    }

    /**
     * @param string|null $twitter
     */
    public function setTwitter(?string $twitter): self
    {
        $this->twitter = $twitter;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getInstagram(): ?string
    {
        return $this->instagram;
    }

    /**
     * @param string|null $instagram
     */
    public function setInstagram(?string $instagram): self
    {
        $this->instagram = $instagram;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getYoutube(): ?string
    {
        return $this->youtube;
    }

    /**
     * @param string|null $youtube
     * @return FederationStructure
     */
    public function setYoutube(?string $youtube): FederationStructure
    {
        $this->youtube = $youtube;
        return $this;
    }

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

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

    /**
     * @return list<string>|null
     */
    public function getPractices(): ?array
    {
        return $this->practices;
    }

    /**
     * @param list<string>|null $practices
     * @return FederationStructure
     */
    public function setPractices(?array $practices): FederationStructure
    {
        $this->practices = $practices;
        return $this;
    }

    /**
     * @return int|null
     */
    public function getParentId(): ?int
    {
        return $this->parentId;
    }

    /**
     * @param int|null $parentId
     * @return FederationStructure
     */
    public function setParentId(?int $parentId): FederationStructure
    {
        $this->parentId = $parentId;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getParentName(): ?string
    {
        return $this->parentName;
    }

    /**
     * @param string|null $parentName
     * @return FederationStructure
     */
    public function setParentName(?string $parentName): FederationStructure
    {
        $this->parentName = $parentName;
        return $this;
    }

    /**
     * @return list<string>
     */
    public function getParents(): array
    {
        return $this->parents;
    }

    /**
     * @param list<string> $parents
     * @return FederationStructure
     */
    public function setParents(array $parents): FederationStructure
    {
        $this->parents = $parents;
        return $this;
    }
}
