<?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="customer_meeting_participant",indexes={@ORM\Index(name="search_participant_idx", columns={"customer_meeting_id", "participant_user_id"})},
 *                                  uniqueConstraints={@UniqueConstraint(name="unique_participant", columns={"customer_meeting_id", "participant_user_id"})})
 */
class EntCustomerMeetingParticipant implements IEntity
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    protected $id;

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

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


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

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

        $this->customer_meeting_id = $entCustomerMeeting->getId();
        $this->participant_user_id = $entParticipantUser->getId();
    }

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

    /**
     * @return mixed
     */
    public function getCustomerMeetingId()
    {
        return $this->customer_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,
            'customer_meeting_id' => $this->customer_meeting_id,
            'participant_user_id' => $this->participant_user_id,
        ];
    }

}
