<?php

namespace NPS\Entity;

use Doctrine\ORM\Mapping as ORM;
use DateTime;

/**
 * File entity
 * @author Lukas Korinek
 * @ORM\Entity
 * @ORM\Table(name="`file`")
 */
class FileEntity implements IEntity
{
    use TIdProperty;
    use TCreate;

    /**
     * @ORM\Column(type="datetime", name="date_created", length=250, nullable=false)
     * @var DateTime
     */
    public $dateCreated;

    /**
     * @ORM\ManyToOne(targetEntity="UserEntity")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true)
     * @var UserEntity
     */
    public $uploader;

    /**
     * Web path to the file (not including base url which can vary)
     * @ORM\Column(type="string", name="path", length=400, nullable=false)
     * @var string
     */
    public $path;

    /**
     * Real path to the file
     * @ORM\Column(type="string", name="realpath", length=400, nullable=false)
     * @var string
     */
    public $realpath;

    /**
     * Original filename of the uploaded file
     * @ORM\Column(type="string", name="filename", length=400, nullable=false)
     * @var string
     */
    public $filename;

    /**
     * Type of the file
     * @ORM\Column(type="integer", name="type", nullable=false)
     * @var string
     */
    public $type;

    /**
     * File description / note
     * @ORM\Column(type="text", name="note", length=400, nullable=true)
     * @var string
     */
    public $note;

    /**
     * Tags for the file entity, determining its purpose accross the app
     * @ORM\Column(type="simple_array", name="tags", nullable=false)
     * @var array
     */
    public $tags;

    public function __construct()
    {
        $this->dateCreated = new \DateTime();
    }

}

