upload and retrieve document

This commit is contained in:
2018-06-06 22:19:54 +02:00
parent eda8f2c033
commit b5bf8b8884
17 changed files with 688 additions and 5 deletions

View File

@@ -40,9 +40,12 @@ class Document implements HasScopeInterface
private $category;
/**
* @ORM\Column(type="text")
* @ORM\ManyToOne(
* targetEntity="Chill\DocStoreBundle\Entity\StoredObject",
* cascade={"persist"}
* )
*/
private $content;
private $object;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
@@ -65,7 +68,7 @@ class Document implements HasScopeInterface
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
@@ -157,4 +160,16 @@ class Document implements HasScopeInterface
return $this;
}
public function getObject(): ?StoredObject
{
return $this->object;
}
public function setObject(StoredObject $object)
{
$this->object = $object;
return $this;
}
}

164
Entity/StoredObject.php Normal file
View File

@@ -0,0 +1,164 @@
<?php
/*
*
*/
namespace Chill\DocStoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use ChampsLibres\AsyncUploaderBundle\Model\AsyncFileInterface;
/**
* Represent a document stored in an object store
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*
* @ORM\Entity()
* @ORM\Table("chill_doc.stored_object")
*/
class StoredObject implements AsyncFileInterface
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="text")
*/
private $filename;
/**
* @ORM\Column(type="json_array", name="key")
* @var array
*/
private $keyInfos = array();
/**
*
* @var int[]
* @ORM\Column(type="json_array", name="iv")
*/
private $iv = array();
/**
*
* @var \DateTime
* @ORM\Column(type="datetime", name="creation_date")
*/
private $creationDate;
/**
*
* @var string
* @ORM\Column(type="text", name="type")
*/
private $type = '';
/**
*
* @var array
* @ORM\Column(type="json_array", name="datas")
*/
private $datas = [];
public function __construct()
{
$this->creationDate = new \DateTime();
}
public function getId()
{
return $this->id;
}
public function getFilename()
{
return $this->filename;
}
public function getCreationDate(): \DateTime
{
return $this->creationDate;
}
public function getType()
{
return $this->type;
}
public function getDatas()
{
return $this->datas;
}
public function setFilename($filename)
{
$this->filename = $filename;
return $this;
}
public function setCreationDate(\DateTime $creationDate)
{
$this->creationDate = $creationDate;
return $this;
}
public function setType($type)
{
$this->type = $type;
return $this;
}
public function setDatas(array $datas)
{
$this->datas = $datas;
return $this;
}
public function getObjectName()
{
return $this->getFilename();
}
public function setAsyncFile(/*AsyncFileInterface*/ $async)
{
dump($async);
//$this->setFilename($async->getObjectName());
}
public function getAsyncFile()
{
return $this;
}
public function getKeyInfos()
{
return $this->keyInfos;
}
public function getIv()
{
return $this->iv;
}
public function setKeyInfos($keyInfos)
{
$this->keyInfos = $keyInfos;
return $this;
}
public function setIv($iv)
{
$this->iv = $iv;
return $this;
}
}