<?php

namespace App\Entity;

use App\Entity\Traits\TimestampableTrait;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\DiscriminatorColumn;
use Doctrine\ORM\Mapping\DiscriminatorMap;
use Doctrine\ORM\Mapping\InheritanceType;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity()
 * @ORM\Table("file_association")
 * @InheritanceType("SINGLE_TABLE")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"campaign" = "FileAssociationCampaign",
 *                      "notice" = "FileAssociationNotice",
 *                      "content" = "FileAssociationContent",
 *                      "negotiationMessage" = "FileAssociationNegotiationMessage",
 *                      "task" = "FileAssociationTask",
 *                      "comment" = "FileAssociationComment"
 * })
 */
abstract class FileAssociationAbstract
{
    use TimestampableTrait;

    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

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

    /**
     * @ORM\OneToOne(targetEntity="App\Entity\File")
     * @Assert\NotBlank()
     */
    private $file;

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

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

    /**
     * @param mixed $type
     *
     * @return FileAssociationAbstract
     */
    public function setType($type)
    {
        $this->type = $type;

        return $this;
    }

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

    /**
     * @param mixed $file
     *
     * @return FileAssociationAbstract
     */
    public function setFile($file)
    {
        $this->file = $file;

        return $this;
    }

    public function getDataType(): String
    {
        return 'fileassociation';
    }
}
