<?php

namespace App\Model\Entities\Components;

use App\Model\Entities\Image;
use App\Model\Entities\Reference;
use App\Model\Entities\Security\User;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;


/**
 * @ORM\Entity
 */
abstract class TextEntryVersion extends TextEntryData
{
    /**
     * @var ArrayCollection
     * @ORM\ManyToMany(targetEntity="App\Model\Entities\Image")
     */
    protected $images;

    /**
     * @var ArrayCollection
     * @ORM\ManyToMany(targetEntity="App\Model\Entities\Reference")
     */
    protected $references;

    /**
     * TextEntryVersion constructor.
     * @param User $createdBy
     * @param TextEntry $textEntry
     * @param $language
     */
    public function __construct(User $createdBy, TextEntry $textEntry, $language)
    {
        parent::__construct($createdBy, $language);

        $this->textEntry = $textEntry;
        $this->images = new ArrayCollection();
        $this->references = new ArrayCollection();
    }


    /**
     * @param Image $image
     */
    public function addImage(Image $image)
    {
        $this->images->add($image);
    }

    /**
     * @param Image $image
     */
    public function removeImage(Image $image)
    {
        $this->images->remove($image);
    }

    /**
     * @return ArrayCollection
     */
    public function getImages()
    {
        return $this->images;
    }

    /**
     * @param Reference $reference
     */
    public function addReference(Reference $reference)
    {
        $this->references->add($reference);
    }

    /**
     * @param Reference $reference
     */
    public function removeReference(Reference $reference)
    {
        $this->references->remove($reference);
    }

    /**
     * @return ArrayCollection
     */
    public function getReferences()
    {
        return $this->references;
    }


}