<?php

namespace AppBundle\Entity\Core;

use AppBundle\Entity\Organization\Organization;
use Doctrine\ORM\Mapping as ORM;
use Dunglas\ApiBundle\Annotation\Iri;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Serializer\Annotation\Groups;
use AppBundle\Annotation\DefaultField;
use AppBundle\Entity\Traits\TimestampableEntity;
use AppBundle\Entity\Traits\CreatorUpdaterEntity;

/**
 * Classe de base des notifications et des tips
 *
 *
 */
#[ORM\Entity]
#[ORM\Table(name: 'Information')]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
#[ORM\DiscriminatorMap(['notification' => 'Notification', 'tips' => 'Tips'])]
abstract class AbstractInformation
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['information', 'tips', 'notification'])]
    private $id;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', length: 40, nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Groups(['information', 'tips', 'notification'])]
    private $name;
    /**
     * @var \DateTime
     */
    #[ORM\Column(type: 'datetime', nullable: true)]
    #[Assert\DateTime]
    #[Groups(['information', 'tips', 'notification'])]
    private $datetimeStart;
    /**
     * @var \DateTime
     */
    #[ORM\Column(type: 'datetime', nullable: true)]
    #[Assert\DateTime]
    #[Groups(['information', 'tips', 'notification'])]
    private $datetimeEnd;
    /**
     * @var bool
     */
    #[ORM\Column(type: 'boolean', options: ['default' => true])]
    #[Assert\Type(type: 'boolean')]
    #[Assert\NotNull]
    #[Groups(['information', 'tips', 'notification'])]
    private $activate = true;
    /**
     * @var bool
     */
    #[ORM\Column(type: 'boolean', options: ['default' => 0])]
    #[Assert\Type(type: 'boolean')]
    #[Assert\NotNull]
    #[Groups(['information', 'tips', 'notification'])]
    private $isSystem = false;
    /**
     * @var ArrayCollection<NotificationUser>
     */
    #[Assert\Valid]
    #[ORM\OneToMany(targetEntity: 'NotificationUser', mappedBy: 'notification', cascade: ['persist'], orphanRemoval: true)]
    #[Groups(['information', 'tips', 'notification'])]
    private $notificationUsers;
    /**
     * The constructor
     */
    public function __construct() {
        $this->notificationUsers = 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;
    }
    /**
     * Set activate
     *
     * @param boolean $activate
     *
     * @return AbstractInformation
     */
    public function setActivate($activate)
    {
        $this->activate = $activate;

        return $this;
    }
    /**
     * Get activate
     *
     * @return boolean
     */
    public function getActivate()
    {
        return $this->activate;
    }
    /**
     * Set isSystem
     *
     * @param boolean $isSystem
     *
     * @return AbstractInformation
     */
    public function setIsSystem($isSystem)
    {
        $this->isSystem = $isSystem;

        return $this;
    }
    /**
     * Get isSystem
     *
     * @return boolean
     */
    public function getIsSystem()
    {
        return $this->isSystem;
    }
    /**
     * Set name
     *
     * @param string $name
     *
     * @return AbstractInformation
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }
    /**
     * Get name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }
    /**
     * Set datetimeStart
     *
     * @param \DateTime $datetimeStart
     *
     * @return AbstractInformation
     */
    public function setDatetimeStart($datetimeStart)
    {
        $this->datetimeStart = $datetimeStart;

        return $this;
    }
    /**
     * Get datetimeStart
     *
     * @return \DateTime
     */
    public function getDatetimeStart()
    {
        return $this->datetimeStart;
    }
    /**
     * Set datetimeEnd
     *
     * @param \DateTime $datetimeEnd
     *
     * @return AbstractInformation
     */
    public function setDatetimeEnd($datetimeEnd)
    {
        $this->datetimeEnd = $datetimeEnd;

        return $this;
    }
    /**
     * Get datetimeEnd
     *
     * @return \DateTime
     */
    public function getDatetimeEnd()
    {
        return $this->datetimeEnd;
    }
    /**
     * Adds notificationUser.
     *
     * @param NotificationUser $notificationUser
     * @return $this
     */
    public function addNotificationUser(NotificationUser $notificationUser) {
        $notificationUser->setNotification($this);
        $this->notificationUsers->add($notificationUser);
        return $this;
    }
    /**
     * Remove $notificationUse.
     *
     * @param NotificationUser $notificationUser
     * @return $this
     */
    public function removeNotificationUser(NotificationUser $notificationUser) {
        $notificationUser->setNotification(null);
        $this->notificationUsers->remove($notificationUser);
        return $this;
    }
    /**
     * Gets notificationUsers
     *
     * @return ArrayCollection<NotificationUser>
     */
    public function getNotificationUsers() {
        return $this->notificationUsers;
    }
}
