<?php

namespace App\Model\Entities\Components\Article;

use App\Model\Entities\Components\Messenger;
use App\Model\Entities\Components\TextEntry;
use App\Model\Entities\Templates\ArticleTemplate;
use App\Model\Interfaces\IResource;
use App\Model\Interfaces\ITemplate;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 */
class Article extends TextEntry implements IResource
{
    /**
     * @var ArticleTemplate
     * @ORM\ManyToOne(targetEntity="App\Model\Entities\Templates\ArticleTemplate")
     */
    protected $template;

    /**
     * @var Messenger
     * @ORM\ManyToOne(targetEntity="App\Model\Entities\Components\Discussion\Discussion")
     * @ORM\JoinColumn(nullable=true)
     */
    protected $discussion;

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

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

    /**
     * @return ArticleTemplate
     */
    public function getResource()
    {
        return $this->getTemplate();
    }

    /**
     * @return Messenger
     */
    public function getDiscussion()
    {
        return $this->discussion;
    }

    /**
     * @param Messenger $discussion
     */
    public function setDiscussion(Messenger $discussion)
    {
        $this->discussion = $discussion;
    }

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