src/Cms/FileBundle/Entity/Nodes/File.php line 20

Open in your IDE?
  1. <?php
  2. namespace Cms\FileBundle\Entity\Nodes;
  3. use Cms\FileBundle\Entity\Node;
  4. use Cms\FileBundle\Model\FileFlagsBitwise;
  5. use DateTime;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Platform\SecurityBundle\Entity\Identity\Account;
  8. use Reinder83\BinaryFlags\Bits;
  9. /**
  10.  * Class File
  11.  * @package Cms\FileBundle\Entity\Nodes
  12.  *
  13.  * @ORM\Entity(
  14.  *  repositoryClass = "Cms\FileBundle\Doctrine\Nodes\FileRepository"
  15.  * )
  16.  */
  17. abstract class File extends Node
  18. {
  19.     const DISCR 'file';
  20.     const TYPE 'File';
  21.     public const STATUSES__ALLOCATED 0;
  22.     public const STATUSES__UPLOADED 1;
  23.     public const STATUSES__PROCESSED 2;
  24.     public const STATUSES__PENDING_REMOVAL 3;
  25.     /**
  26.      * @var int
  27.      *
  28.      * @ORM\Column(
  29.      *  type = "integer",
  30.      *  nullable = false,
  31.      *  options = {
  32.      *      "default" = File::STATUSES__ALLOCATED
  33.      *  }
  34.      * )
  35.      */
  36.     protected $status self::STATUSES__ALLOCATED;
  37.     /**
  38.      * @var string
  39.      *
  40.      * @ORM\Column(
  41.      *  type = "string",
  42.      *  nullable = false
  43.      * )
  44.      */
  45.     protected $extension;
  46.     /**
  47.      * @var string
  48.      *
  49.      * @ORM\Column(
  50.      *  type = "string",
  51.      *  nullable = false
  52.      * )
  53.      */
  54.     protected $mime;
  55.     /**
  56.      * @var string
  57.      *
  58.      * @ORM\Column(
  59.      *  type = "text",
  60.      *  nullable = true
  61.      * )
  62.      */
  63.     protected $description;
  64.     /**
  65.      * The size of the file in bytes.
  66.      *
  67.      * @var int
  68.      *
  69.      * @ORM\Column(
  70.      *  type = "bigint",
  71.      *  nullable = true
  72.      * )
  73.      */
  74.     protected $size;
  75.     /**
  76.      * @var DateTime|null
  77.      *
  78.      * @ORM\Column(
  79.      *     type = "datetime",
  80.      *     nullable = false
  81.      * )
  82.      */
  83.     protected $uploadedAt;
  84.     /**
  85.      * @var Account|null
  86.      *
  87.      * @ORM\ManyToOne(
  88.      *     targetEntity = "Platform\SecurityBundle\Entity\Identity\Account"
  89.      * )
  90.      * @ORM\JoinColumn(
  91.      *     name = "uploadedBy",
  92.      *     referencedColumnName = "id",
  93.      *     nullable = true,
  94.      *     onDelete = "SET NULL"
  95.      * )
  96.      */
  97.     protected $uploadedBy;
  98.     /**
  99.      * @var string|null
  100.      *
  101.      * @ORM\Column(
  102.      *     type = "text",
  103.      *     nullable = true
  104.      * )
  105.      */
  106.     protected $note;
  107.     /**
  108.      * @var FileFlagsBitwise
  109.      *
  110.      * @ORM\Column(
  111.      *     type = "bitwise_file_flags",
  112.      *     nullable = false,
  113.      *     options = {
  114.      *         "default" = 0
  115.      *     }
  116.      * )
  117.      */
  118.     protected $flags;
  119.     /**
  120.      *
  121.      */
  122.     public function __construct()
  123.     {
  124.         parent::__construct();
  125.         $this->flags = new FileFlagsBitwise(0);
  126.     }
  127.     /**
  128.      * @return int
  129.      */
  130.     public function getStatus()
  131.     {
  132.         return $this->status;
  133.     }
  134.     /**
  135.      * @param int $value
  136.      * @return $this
  137.      */
  138.     public function setStatus($value)
  139.     {
  140.         $this->status $value;
  141.         return $this;
  142.     }
  143.     /**
  144.      * Returns the whole name of the file, name and extension.
  145.      *
  146.      * @return string
  147.      */
  148.     public function getFilename()
  149.     {
  150.         return rtrim($this->getName() . '.' $this->getExtension(), '.');
  151.     }
  152.     /**
  153.      * @return string
  154.      */
  155.     public function getExtension()
  156.     {
  157.         return $this->extension;
  158.     }
  159.     /**
  160.      * @return string
  161.      */
  162.     public function getMime()
  163.     {
  164.         return $this->mime;
  165.     }
  166.     /**
  167.      * @return string
  168.      */
  169.     public function getDescription()
  170.     {
  171.         return $this->description;
  172.     }
  173.     /**
  174.      * @return int
  175.      */
  176.     public function getSize()
  177.     {
  178.         return $this->size;
  179.     }
  180.     /**
  181.      * @param string $value
  182.      * @return $this
  183.      */
  184.     public function setExtension($value)
  185.     {
  186.         $this->extension $value;
  187.         return $this;
  188.     }
  189.     /**
  190.      * @param string $value
  191.      * @return $this
  192.      */
  193.     public function setMime($value)
  194.     {
  195.         $this->mime $value;
  196.         return $this;
  197.     }
  198.     /**
  199.      * @param string $value
  200.      * @return $this
  201.      */
  202.     public function setDescription($value)
  203.     {
  204.         $this->description $value;
  205.         return $this;
  206.     }
  207.     /**
  208.      * @param int $value
  209.      * @return $this
  210.      */
  211.     public function setSize($value)
  212.     {
  213.         $this->size $value;
  214.         return $this;
  215.     }
  216.     /**
  217.      * @return DateTime
  218.      */
  219.     public function getUploadedAt()
  220.     {
  221.         return $this->uploadedAt;
  222.     }
  223.     /**
  224.      * @param DateTime|null $value
  225.      * @return $this
  226.      */
  227.     public function setUploadedAt(DateTime $value null)
  228.     {
  229.         $this->uploadedAt $value;
  230.         return $this;
  231.     }
  232.     /**
  233.      * @return Account|null
  234.      */
  235.     public function getUploadedBy()
  236.     {
  237.         return $this->uploadedBy;
  238.     }
  239.     /**
  240.      * @param Account|null $value
  241.      * @return $this
  242.      */
  243.     public function setUploadedBy(Account $value null)
  244.     {
  245.         $this->uploadedBy $value;
  246.         return $this;
  247.     }
  248.     /**
  249.      * @return string|null
  250.      */
  251.     public function getNote()
  252.     {
  253.         return $this->note;
  254.     }
  255.     /**
  256.      * @param string|null $value
  257.      * @return $this
  258.      */
  259.     public function setNote($value null)
  260.     {
  261.         $this->note $value;
  262.         return $this;
  263.     }
  264.     /**
  265.      * @return FileFlagsBitwise
  266.      */
  267.     public function getFlags()
  268.     {
  269.         return $this->flags;
  270.     }
  271.     /**
  272.      * @param FileFlagsBitwise $value
  273.      * @return $this
  274.      */
  275.     public function setFlags(FileFlagsBitwise $value)
  276.     {
  277.         $this->flags $this->flags->orm($value);
  278.         return $this;
  279.     }
  280.     /**
  281.      * {@inheritdoc}
  282.      */
  283.     public function ui()
  284.     {
  285.         return $this->getFilename();
  286.     }
  287. }