<?php

namespace App\Entity;


use App\Entity\IFace\IEntity;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\UniqueConstraint;
use Symfony\Component\Config\Definition\Exception\Exception;

/**
 * @ORM\Entity
 * @ORM\Table(name="internal_meeting_participant",indexes={@ORM\Index(name="search_participant_idx", columns={"internal_meeting_id", "participant_user_id"})},
 *                                  uniqueConstraints={@UniqueConstraint(name="unique_participant", columns={"internal_meeting_id", "participant_user_id"})})
 */
class EntInternalMeetingParticipant implements IEntity
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    protected $id;

    /**
     * @ORM\Column(type="integer", nullable=false, options={"unsigned" = true})
     */
    protected $internal_meeting_id;

    /**
     * @ORM\Column(type="integer", nullable=false, options={"unsigned" = true})
     */
    protected $participant_user_id;


    /**
     * EntInternalMeetingParticipant constructor.
     * @param ObjectManager $em
     * @param EntInternalMeeting $entInternalMeeting
     * @param EntUser $entParticipantUser
     */
    public function __construct(ObjectManager $em, EntInternalMeeting $entInternalMeeting, EntUser $entParticipantUser)
    {
        if (is_null($entInternalMeeting->getId())) {
            throw new Exception('no id found');
        }

        if (is_null($entParticipantUser->getId())) {
            throw new Exception('no id found');
        }

        $this->internal_meeting_id = $entInternalMeeting->getId();
        $this->participant_user_id = $entParticipantUser->getId();
    }

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

    /**
     * @return mixed
     */
    public function getInternalMeetingId()
    {
        return $this->internal_meeting_id;
    }

    /**
     * @return mixed
     */
    public function getParticipantUserId()
    {
        return $this->participant_user_id;
    }

    /**
     * Client mapper
     * @param ObjectManager $em
     * @param bool $fullMapping
     * @return array
     */
    public function clientMapper(ObjectManager $em, $fullMapping = false)
    {
        return [
            'id' => $this->id,
            'internal_meeting_id' => $this->internal_meeting_id,
            'participant_user_id' => $this->participant_user_id,
        ];
    }

}
