<?php
namespace Cms\FileBundle\Entity\Nodes;
use Cms\FileBundle\Entity\Node;
use Cms\FileBundle\Model\FileFlagsBitwise;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Platform\SecurityBundle\Entity\Identity\Account;
use Reinder83\BinaryFlags\Bits;
/**
* Class File
* @package Cms\FileBundle\Entity\Nodes
*
* @ORM\Entity(
* repositoryClass = "Cms\FileBundle\Doctrine\Nodes\FileRepository"
* )
*/
abstract class File extends Node
{
const DISCR = 'file';
const TYPE = 'File';
public const STATUSES__ALLOCATED = 0;
public const STATUSES__UPLOADED = 1;
public const STATUSES__PROCESSED = 2;
public const STATUSES__PENDING_REMOVAL = 3;
/**
* @var int
*
* @ORM\Column(
* type = "integer",
* nullable = false,
* options = {
* "default" = File::STATUSES__ALLOCATED
* }
* )
*/
protected $status = self::STATUSES__ALLOCATED;
/**
* @var string
*
* @ORM\Column(
* type = "string",
* nullable = false
* )
*/
protected $extension;
/**
* @var string
*
* @ORM\Column(
* type = "string",
* nullable = false
* )
*/
protected $mime;
/**
* @var string
*
* @ORM\Column(
* type = "text",
* nullable = true
* )
*/
protected $description;
/**
* The size of the file in bytes.
*
* @var int
*
* @ORM\Column(
* type = "bigint",
* nullable = true
* )
*/
protected $size;
/**
* @var DateTime|null
*
* @ORM\Column(
* type = "datetime",
* nullable = false
* )
*/
protected $uploadedAt;
/**
* @var Account|null
*
* @ORM\ManyToOne(
* targetEntity = "Platform\SecurityBundle\Entity\Identity\Account"
* )
* @ORM\JoinColumn(
* name = "uploadedBy",
* referencedColumnName = "id",
* nullable = true,
* onDelete = "SET NULL"
* )
*/
protected $uploadedBy;
/**
* @var string|null
*
* @ORM\Column(
* type = "text",
* nullable = true
* )
*/
protected $note;
/**
* @var FileFlagsBitwise
*
* @ORM\Column(
* type = "bitwise_file_flags",
* nullable = false,
* options = {
* "default" = 0
* }
* )
*/
protected $flags;
/**
*
*/
public function __construct()
{
parent::__construct();
$this->flags = new FileFlagsBitwise(0);
}
/**
* @return int
*/
public function getStatus()
{
return $this->status;
}
/**
* @param int $value
* @return $this
*/
public function setStatus($value)
{
$this->status = $value;
return $this;
}
/**
* Returns the whole name of the file, name and extension.
*
* @return string
*/
public function getFilename()
{
return rtrim($this->getName() . '.' . $this->getExtension(), '.');
}
/**
* @return string
*/
public function getExtension()
{
return $this->extension;
}
/**
* @return string
*/
public function getMime()
{
return $this->mime;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @return int
*/
public function getSize()
{
return $this->size;
}
/**
* @param string $value
* @return $this
*/
public function setExtension($value)
{
$this->extension = $value;
return $this;
}
/**
* @param string $value
* @return $this
*/
public function setMime($value)
{
$this->mime = $value;
return $this;
}
/**
* @param string $value
* @return $this
*/
public function setDescription($value)
{
$this->description = $value;
return $this;
}
/**
* @param int $value
* @return $this
*/
public function setSize($value)
{
$this->size = $value;
return $this;
}
/**
* @return DateTime
*/
public function getUploadedAt()
{
return $this->uploadedAt;
}
/**
* @param DateTime|null $value
* @return $this
*/
public function setUploadedAt(DateTime $value = null)
{
$this->uploadedAt = $value;
return $this;
}
/**
* @return Account|null
*/
public function getUploadedBy()
{
return $this->uploadedBy;
}
/**
* @param Account|null $value
* @return $this
*/
public function setUploadedBy(Account $value = null)
{
$this->uploadedBy = $value;
return $this;
}
/**
* @return string|null
*/
public function getNote()
{
return $this->note;
}
/**
* @param string|null $value
* @return $this
*/
public function setNote($value = null)
{
$this->note = $value;
return $this;
}
/**
* @return FileFlagsBitwise
*/
public function getFlags()
{
return $this->flags;
}
/**
* @param FileFlagsBitwise $value
* @return $this
*/
public function setFlags(FileFlagsBitwise $value)
{
$this->flags = $this->flags->orm($value);
return $this;
}
/**
* {@inheritdoc}
*/
public function ui()
{
return $this->getFilename();
}
}