<?php

namespace App\Entity;
use App\Entity\Base\BaseUserType;
use App\Entity\IFace\IEntity;
use App\Utils\Utils;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\Config\Definition\Exception\Exception;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="meeting_type")
 */
class EntMeetingType implements IEntity
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    protected $id;

    /**
     * @ORM\Column(type="string", nullable=false, unique=true)
     */
    protected $type;

    /**
     * @ORM\Column(type="string", nullable=false, unique=true)
     */
    protected $name;

    private static $cacheMeetingTypesById;

    /**
     * Gets static room cycle types
     * @param ObjectManager $em
     * @return array
     */
    public static function getMeetingTypesById(ObjectManager $em)
    {
        if (is_null(self::$cacheMeetingTypesById)) {
            self::$cacheMeetingTypesById = Utils::getSortedObjectsById($em->getRepository('App:EntMeetingType')->findAll());
        }
        return self::$cacheMeetingTypesById;
    }

    public function __construct($type, $name)
    {
        $this->type = $type;
        $this->name = $name;
    }

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

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

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

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


}
