<?php 

namespace NPS\Entity;

use Doctrine\ORM\Mapping as ORM;
use NPS\Entity\UserEntity;

/**
 * Access grant token entity 
 * Decides whether a particular user has access to a knowledge base identified by its bind id
 * @author Lukas Korinek
 * @ORM\Entity
 * @ORM\Table(name="`access_grant`")
 */
class AccessGrantEntity
{
    use TIdProperty;

    /**
     * User for which the grant is issued
     * @ORM\ManyToOne(targetEntity="UserEntity", inversedBy="grants")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true)
     * @var UserEntity
     */
    public $user;

    /**
     * Knowledge base bind id
     * @ORM\Column(name="bind_id", type="integer", nullable=false)
     * @var int
     */
    public $bindId;

    public function __construct(UserEntity $user, $bindId)
    {
        $this->user = $user;
        $this->bindId = $bindId;
    }
}

