<?php
declare(strict_types=1);

namespace App\Entity\Public;

use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\NumericFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
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
 */
#[ORM\Entity(repositoryClass: FederationStructureRepository::class, readOnly: true)]
#[ORM\Table(name: "view_federation_structures")]
#[ApiResource(
    collectionOperations: [
        'get' => [
            'method' => 'GET',
            'path' => '/public/federation_structures',
            'normalization_context' => ['groups' => ['federation_structure_collection_get']],
        ]
    ],
    itemOperations: [
        'get' => [
            'method' => 'GET',
            'path' => '/public/federation_structures/{id}',
            'requirements' => ['id' => '\d+'],
            'normalization_context' => ['groups' => ['federation_structure_item_get']]
        ]
    ],
    attributes: ["pagination_enabled" => false]
)]
#[ApiFilter(SearchFilter::class, properties: ['name' => 'partial', 'city' => 'exact'])]
#[ApiFilter(NumericFilter::class, properties: ['id', 'parentId'])]
#[ApiFilter(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')]
    #[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]
    #[Groups(["federation_structure_item_get", "federation_structure_collection_get"])]
    private ?string $website;

    #[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;

    #[ORM\Column(type: 'json')]
    #[Groups(["federation_structure_item_get"])]
    private ?array $articles;

    #[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;

    #[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): self
    {
        $this->id = $id;
        return $this;
    }

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

    /**
     * @param string $name
     * @return FederationStructure
     */
    public function setName(string $name): self
    {
        $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): self
    {
        $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): self
    {
        $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): self
    {
        $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): self
    {
        $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): self
    {
        $this->website = $website;
        return $this;
    }

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

    /**
     * @param array $addresses
     * @return FederationStructure
     */
    public function setAddresses(array $addresses): self
    {
        $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): self
    {
        $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): self
    {
        $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): self
    {
        $this->youtube = $youtube;

        return $this;
    }

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

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

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

    /**
     * @param array|null $practices
     * @return FederationStructure
     */
    public function setPractices(?array $practices): self
    {
        $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): self
    {
        $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): self
    {
        $this->parentName = $parentName;
        return $this;
    }

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

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