<?php
namespace AppBundle\Entity\Place;

use AppBundle\Entity\Booking\Event;
use AppBundle\Entity\Core\AddressPostal;
use AppBundle\Entity\Core\Tagg;
use AppBundle\Entity\Traits\ContactPointType;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Entity\Traits\TimestampableEntity;
use AppBundle\Entity\Traits\CreatorUpdaterEntity;
use AppBundle\Entity\Core\ContactInterface;

/**
* Description of AbstractBooking
*
* @author sebastienhupin
*
* @see http://schema.org/Booking Documentation on Schema.org
*
*
*/
#[ORM\Entity]
#[ORM\Table(name: 'Place')]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
#[ORM\DiscriminatorMap(['place' => 'Place', 'place_system' => 'PlaceSystem'])]
#[ORM\Entity]
abstract class AbstractPlace implements ContactInterface
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    use ContactPointType;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['place', 'placesystem', 'equipment_list', 'equipmentcontrol_list_equipment', 'equipmentrepair_list_equipment', 'equipmentaccounting_list', 'equipmentmediatheque_list', 'equipmentcostume_list', 'place_list', 'placecontrol_list', 'placerepair_list', 'examenconvocation_list_examen', 'planning_list', 'event_details', 'examen_details', 'course_details', 'educationalproject_details', 'planning_detail'])]
    private $id;
    /**
     * @var string The name of the item.
     */
    #[Assert\Type(type: 'string')]
    #[ORM\Column(type: 'string', nullable: true)]
    #[Groups(['place', 'placesystem', 'place_reference', 'placesystem_reference', 'equipment_list_placestorage', 'equipment_list_placewhereisused', 'equipmentrent_list_equipment', 'equipmentloan_list_equipment', 'equipmentcontrol_list_equipment', 'equipmentrepair_list_equipment', 'equipmentaccounting_list_placewhereisused', 'equipmentmediatheque_list_placewhereisused', 'equipmentmediatheque_list_placestorage', 'equipmentcostume_list_placewhereisused', 'place_list', 'placecontrol_list_place', 'placerepair_list_place', 'examenconvocation_list_examen', 'planning_list', 'event_details_place', 'event_details_placesystem', 'examen_details_place', 'course_details_place', 'educationalproject_details_place', 'reportmessage', 'invitations_list_event', 'planning_detail_place', 'planning_detail_placesystem', 'student_list_courses'])]
    private $name;
    /**
     * @var AddressPostal
     */
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Core\AddressPostal', inversedBy: 'places', cascade: ['persist'])]
    #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
    #[Assert\Valid]
    #[Groups(['place', 'placesystem', 'place_list', 'place_reference', 'placesystem_reference', 'planning_detail_place', 'planning_list', 'planning_detail_placesystem', 'activity_report'])]
    private $addressPostal;
    /**
     * @var ArrayCollection<Event>
     */
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\Event', mappedBy: 'place')]
    #[Groups(['place_booking'])]
    private $events;
    /**
     * @var bool
     */
    #[Assert\Type(type: 'boolean')]
    #[ORM\Column(type: 'boolean', nullable: true, options: ['default' => false])]
    #[Groups(['place', 'placesystem', 'place_reference'])]
    private $isSystem;
    /**
     * @var ArrayCollection<Tagg>
     */
    #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'places')]
    #[Assert\Valid]
    #[ORM\JoinTable(name: 'tag_place', joinColumns: [], inverseJoinColumns: [])]
    #[ORM\JoinColumn(name: 'place_id', referencedColumnName: 'id')]
    #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
    #[Groups(['place_tags', 'manage_tags', 'place_list'])]
    private $tags;
    public function __construct()
    {
        $this->events = new ArrayCollection();
        $this->tags = new ArrayCollection();
    }
    /**
     * 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 name.
     *
     * @param string $name
     *
     * @return $this
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }
    /**
     * Gets name.
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }
    /**
     * Sets addressPostal.
     *
     * @param AddressPostal $addressPostal
     *
     * @return $this
     */
    public function setAddressPostal(AddressPostal $addressPostal = null)
    {
        $this->addressPostal = $addressPostal;

        return $this;
    }
    /**
     * Gets addressPostal.
     *
     * @return AddressPostal
     */
    public function getAddressPostal()
    {
        return $this->addressPostal;
    }
    /**
     * Sets isSystem.
     *
     * @param bool $isSystem
     *
     * @return $this
     */
    public function setIsSystem($isSystem)
    {
        $this->isSystem = $isSystem;

        return $this;
    }
    /**
     * Gets isSystem.
     *
     * @return bool
     */
    public function getIsSystem()
    {
        return $this->isSystem;
    }
    /**
     * Add event
     *
     * @param \AppBundle\Entity\Booking\Event $event
     *
     * @return Place
     */
    public function addEvent(\AppBundle\Entity\Booking\Event $event)
    {
        $this->events[] = $event;

        return $this;
    }
    /**
     * Remove event
     *
     * @param \AppBundle\Entity\Booking\Event $event
     */
    public function removeEvent(\AppBundle\Entity\Booking\Event $event)
    {
        $this->events->removeElement($event);
    }
    /**
     * Get events
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getEvents()
    {
        return $this->events;
    }
    /**
     *
     * {@inheritdoc}
     */
    public function getContact()
    {
        return $this;
    }
    /**
     *
     * {@inheritdoc}
     */
    public function getContactAddress()
    {
        return $this->getAddressPostal();
    }
    /**
     *
     * {@inheritdoc}
     */
    public function getContactName()
    {
        return $this->getName();
    }
    /**
     *
     * {@inheritdoc}
     */
    public function getContactContactPoint()
    {
        return $this->getContactPointPrincipal();
    }
    /**
     * Add tag
     *
     * @param \AppBundle\Entity\Core\Tagg $tag
     *
     * @return AbstractPlace
     */
    public function addTag(\AppBundle\Entity\Core\Tagg $tag)
    {
        $this->tags[] = $tag;

        return $this;
    }
    /**
     * Remove tag
     *
     * @param \AppBundle\Entity\Core\Tagg $tag
     */
    public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
    {
        $this->tags->removeElement($tag);
    }
    /**
     * Get tags
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getTags()
    {
        return $this->tags;
    }
}
