<?php

namespace App\Model\Entities;

use App\Model\Entities\Security\User;
use App\Model\Entities\Templates\SiteTemplate;
use App\Model\Interfaces\ICommonRecord;
use App\Model\Interfaces\IResource;
use App\Model\Interfaces\ISite;
use App\Model\Interfaces\ITemplate;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="site")
 * @ORM\InheritanceType(value="JOINED")
 * @ORM\DiscriminatorColumn(name="type")
 */
class PortalSite extends BaseNamedRecord implements ISite, ICommonRecord, IResource
{
    /**
     * @var SiteTemplate
     * @ORM\ManyToOne(targetEntity="App\Model\Entities\Templates\SiteTemplate")
     */
    protected $template;

    /**
     * @ORM\Column(type="boolean")
     */
    protected $isGlobalSite;

    public function __construct(User $createdBy)
    {
        parent::__construct($createdBy);

        $this->setIsGlobalSite(false);
    }

    /**
     * @return SiteTemplate
     */
    public function getTemplate() : SiteTemplate
    {
        return $this->template;
    }

    /**
     * @param SiteTemplate $template
     */
    public function setTemplate(SiteTemplate $template)
    {
        $this->template = $template;
    }

    /**
     * @return bool
     */
    public function isGlobalSite() : bool
    {
        return $this->isGlobalSite;
    }

    /**
     * @param bool $isGlobalSite
     */
    public function setIsGlobalSite(bool $isGlobalSite)
    {
        $this->isGlobalSite = $isGlobalSite;
    }

    public function isGameSite() : bool
    {
        return false;
    }

    public function isGuildSite() : bool
    {
        return false;
    }

    public function getResourceTemplate() : ITemplate
    {
        return $this->getTemplate();
    }
}