187 lines
3.6 KiB
PHP

<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\DocStoreBundle\Entity;
use ChampsLibres\AsyncUploaderBundle\Model\AsyncFileInterface;
use ChampsLibres\AsyncUploaderBundle\Validator\Constraints\AsyncFileExists;
use ChampsLibres\WopiLib\Contract\Entity\Document;
use DateTime;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
use Symfony\Component\Serializer\Annotation as Serializer;
/**
* Represent a document stored in an object store.
*
* @ORM\Entity
* @ORM\Table("chill_doc.stored_object")
* @AsyncFileExists(
* message="The file is not stored properly"
* )
*/
class StoredObject implements AsyncFileInterface, Document
{
/**
* @ORM\Column(type="datetime", name="creation_date")
* @Serializer\Groups({"read", "write"})
*/
private DateTimeInterface $creationDate;
/**
* @ORM\Column(type="json", name="datas")
* @Serializer\Groups({"read", "write"})
*/
private array $datas = [];
/**
* @ORM\Column(type="text")
* @Serializer\Groups({"read", "write"})
*/
private $filename;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"read", "write"})
*/
private $id;
/**
* @var int[]
* @ORM\Column(type="json", name="iv")
* @Serializer\Groups({"read", "write"})
*/
private array $iv = [];
/**
* @ORM\Column(type="json", name="key")
* @Serializer\Groups({"read", "write"})
*/
private array $keyInfos = [];
/**
* @ORM\Column(type="text", name="type")
* @Serializer\Groups({"read", "write"})
*/
private string $type = '';
/**
* @ORM\Column(type="uuid", unique=true)
* @Serializer\Groups({"read", "write"})
*/
private UuidInterface $uuid;
public function __construct()
{
$this->creationDate = new DateTime();
$this->uuid = Uuid::uuid4();
}
public function getCreationDate(): DateTime
{
return $this->creationDate;
}
public function getDatas()
{
return $this->datas;
}
public function getFilename()
{
return $this->filename;
}
public function getId()
{
return $this->id;
}
public function getIv()
{
return $this->iv;
}
public function getKeyInfos()
{
return $this->keyInfos;
}
/**
* @deprecated Use method "getFilename()".
*/
public function getObjectName()
{
return $this->getFilename();
}
public function getType()
{
return $this->type;
}
public function getUuid(): UuidInterface
{
return $this->uuid;
}
public function getWopiDocId(): string
{
return (string) $this->uuid;
}
public function setCreationDate(DateTime $creationDate)
{
$this->creationDate = $creationDate;
return $this;
}
public function setDatas(array $datas)
{
$this->datas = $datas;
return $this;
}
public function setFilename($filename)
{
$this->filename = $filename;
return $this;
}
public function setIv($iv)
{
$this->iv = $iv;
return $this;
}
public function setKeyInfos($keyInfos)
{
$this->keyInfos = $keyInfos;
return $this;
}
public function setType($type)
{
$this->type = $type;
return $this;
}
}