<?php

namespace AppBundle\Entity\Organization;

use AppBundle\Annotation\DefaultField;
use AppBundle\Entity\Core\AddressPostal;
use AppBundle\Enum\Core\AddressPostalTypeEnum;
use Doctrine\ORM\Mapping as ORM;
use Dunglas\ApiBundle\Annotation\Iri;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Entity\Traits\TimestampableEntity;
use AppBundle\Entity\Traits\CreatorUpdaterEntity;

/**
 * Lien entre une Organization et une AdressPostal, associé à un type
 *
 * @Iri("http://schema.org/OrganizationAddressPostal")
 */
#[ORM\Entity]
#[Assert\Callback(['AppBundle\Validator\Constraints\Organization\OrganizationAddressPostalValidator', 'validate'])]
class OrganizationAddressPostal
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['organizationaddresspostal', 'network_list', 'federations_list', 'networkmanagers_list_organization', 'network_artist_school_list', 'organization_details', 'organization_cotisation_steps', 'cmf_network_organizations', 'organization_params_list'])]
    private $id;
    /**
     * @var Organization
     *
     * @DefaultField
     */
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization', inversedBy: 'organizationAddressPostal')]
    #[ORM\JoinColumn(nullable: false)]
    #[Assert\NotNull]
    #[Groups(['organizationaddresspostal'])]
    private $organization;
    /**
     * @var AddressPostal
     */
    #[Assert\Valid]
    #[ORM\OneToOne(targetEntity: 'AppBundle\Entity\Core\AddressPostal', cascade: ['persist', 'remove'], orphanRemoval: true, fetch: 'EAGER')]
    #[ORM\JoinColumn(nullable: false)]
    #[Assert\NotNull]
    #[Groups(['organizationaddresspostal', 'organizationaddresspostal_reference', 'network_list_organizationaddresspostal', 'federations_list_organizationaddresspostal', 'networkmanagers_list_organization', 'network_artist_school_list_organizationaddresspostal', 'organization_details_organizationaddresspostal', 'network_artist_school_list_organizationaddresspostalprincipal', 'network_artist_school_list_organizationaddresspostalcontact', 'network_artist_school_list_organizationaddresspostalbill', 'organization_cotisation_steps_organizationaddresspostal', 'template', 'cmf_network_organizations_organizationaddresspostalprincipal', 'organization_params_list_organizationaddresspostal'])]
    private $addressPostal;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string')]
    #[Assert\Type(type: 'string')]
    #[Assert\NotNull]
    #[Assert\Choice(callback: ['AppBundle\Enum\Core\AddressPostalTypeEnum', 'toArray'])]
    #[Groups(['organizationaddresspostal', 'organizationaddresspostal_reference', 'network_list_organizationaddresspostal', 'federations_list_organizationaddresspostal', 'networkmanagers_list_organization', 'network_artist_school_list_organizationaddresspostal', 'organization_details_organizationaddresspostal', 'organization_cotisation_steps_organizationaddresspostal', 'organization_params_list_organizationaddresspostal'])]
    private $type;
    /**
     * Sets id.
     *
     * @param int $id
     *
     * @return $this
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }
    /**
     * Gets id.
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }
    /**
     * Sets organization.
     *
     * @param Organization $organization
     *
     * @return $this
     */
    public function setOrganization(Organization $organization)
    {
        $this->organization = $organization;

        return $this;
    }
    /**
     * Gets organization.
     *
     * @return Organization
     */
    public function getOrganization()
    {
        return $this->organization;
    }
    /**
     * Sets address postal.
     *
     * @param AddressPostal $addressPostal
     *
     * @return $this
     */
    public function setAddressPostal(AddressPostal $addressPostal)
    {
        $this->addressPostal = $addressPostal;

        return $this;
    }
    /**
     * Gets address postal.
     *
     * @return AddressPostal
     */
    public function getAddressPostal()
    {
        return $this->addressPostal;
    }
    /**
     * Sets type.
     *
     * @param string $type
     *
     * @return $this
     */
    public function setType($type)
    {
        $this->type = $type;

        return $this;
    }
    /**
     * Gets type.
     *
     * @return string
     */
    public function getType()
    {
        return $this->type;
    }
}
