mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
improve doc storing
This commit is contained in:
parent
32402d8c7a
commit
0eccda06d6
@ -49,6 +49,9 @@ class Document implements HasScopeInterface
|
|||||||
* cascade={"persist"}
|
* cascade={"persist"}
|
||||||
* )
|
* )
|
||||||
* @Assert\Valid()
|
* @Assert\Valid()
|
||||||
|
* @Assert\NotNull(
|
||||||
|
* message="Upload a document"
|
||||||
|
* )
|
||||||
*/
|
*/
|
||||||
private $object;
|
private $object;
|
||||||
|
|
||||||
@ -113,18 +116,6 @@ class Document implements HasScopeInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContent(): ?string
|
|
||||||
{
|
|
||||||
return $this->content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setContent(string $content): self
|
|
||||||
{
|
|
||||||
$this->content = $content;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get scope
|
* Get scope
|
||||||
*
|
*
|
||||||
|
@ -37,15 +37,16 @@ class DocumentCategory
|
|||||||
* @ORM\Column(type="json_array")
|
* @ORM\Column(type="json_array")
|
||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
public function getBundleId() // ::class BundleClass (FQDN)
|
public function __construct($bundleId, $idInsideBundle)
|
||||||
{
|
|
||||||
return $this->bundleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setBundleId($bundleId)
|
|
||||||
{
|
{
|
||||||
$this->bundleId = $bundleId;
|
$this->bundleId = $bundleId;
|
||||||
|
$this->idInsideBundle = $idInsideBundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBundleId() // ::class BundleClass (FQDN)
|
||||||
|
{
|
||||||
|
return $this->bundleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIdInsideBundle()
|
public function getIdInsideBundle()
|
||||||
@ -53,13 +54,6 @@ class DocumentCategory
|
|||||||
return $this->idInsideBundle;
|
return $this->idInsideBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setIdInsideBundle($idInsideBundle): self
|
|
||||||
{
|
|
||||||
$this->idInsideBundle = $idInsideBundle;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDocumentClass()
|
public function getDocumentClass()
|
||||||
{
|
{
|
||||||
return $this->documentClass;
|
return $this->documentClass;
|
||||||
|
@ -74,6 +74,7 @@ class PersonDocumentType extends AbstractType
|
|||||||
])
|
])
|
||||||
->add('date', ChillDateType::class)
|
->add('date', ChillDateType::class)
|
||||||
->add('category', EntityType::class, array(
|
->add('category', EntityType::class, array(
|
||||||
|
'placeholder' => 'Choose a document category',
|
||||||
'class' => 'ChillDocStoreBundle:DocumentCategory',
|
'class' => 'ChillDocStoreBundle:DocumentCategory',
|
||||||
'query_builder' => function (EntityRepository $er) {
|
'query_builder' => function (EntityRepository $er) {
|
||||||
return $er->createQueryBuilder('c')
|
return $er->createQueryBuilder('c')
|
||||||
|
@ -31,14 +31,17 @@ class StoredObjectType extends AbstractType
|
|||||||
->get('keyInfos')
|
->get('keyInfos')
|
||||||
->addModelTransformer(new CallbackTransformer(
|
->addModelTransformer(new CallbackTransformer(
|
||||||
[$this, 'transform'], [$this, 'reverseTransform']
|
[$this, 'transform'], [$this, 'reverseTransform']
|
||||||
))
|
));
|
||||||
;
|
|
||||||
$builder
|
$builder
|
||||||
->get('iv')
|
->get('iv')
|
||||||
->addModelTransformer(new CallbackTransformer(
|
->addModelTransformer(new CallbackTransformer(
|
||||||
[$this, 'transform'], [$this, 'reverseTransform']
|
[$this, 'transform'], [$this, 'reverseTransform']
|
||||||
))
|
));
|
||||||
;
|
|
||||||
|
$builder
|
||||||
|
->addModelTransformer(new CallbackTransformer(
|
||||||
|
[ $this, 'transformObject'], [$this, 'reverseTransformObject']
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBlockPrefix()
|
public function getBlockPrefix()
|
||||||
@ -70,4 +73,22 @@ class StoredObjectType extends AbstractType
|
|||||||
|
|
||||||
return \json_encode($object);
|
return \json_encode($object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function transformObject($object = null)
|
||||||
|
{
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function reverseTransformObject($object)
|
||||||
|
{
|
||||||
|
if (NULL === $object) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL === $object->getFilename()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,5 @@ Editing document for %name%: Modification d'un document pour %name%
|
|||||||
Edit Document: Modification d'un document
|
Edit Document: Modification d'un document
|
||||||
Existing document: Document existant
|
Existing document: Document existant
|
||||||
The document is successfully updated: Le document est mis à jour
|
The document is successfully updated: Le document est mis à jour
|
||||||
|
No document to download: Aucun document à télécharger
|
||||||
|
'Choose a document category': Choisissez une catégorie de document
|
||||||
|
@ -1 +1,2 @@
|
|||||||
The file is not stored properly: Le fichier n'est pas téléchargé correctement
|
The file is not stored properly: Le fichier n'est pas téléchargé correctement
|
||||||
|
Upload a document: Téléversez un document
|
@ -1,3 +1,7 @@
|
|||||||
{% macro download_button(storedObject, filename = null) %}
|
{% macro download_button(storedObject, filename = null) %}
|
||||||
<a class="sc-button bt-download" data-label-preparing="{{ ('Preparing'|trans ~ '...')|escape('html_attr') }}" data-label-ready="{{ 'Ready to show'|trans|escape('html_attr') }}" data-download-button data-key="{{ storedObject.keyInfos|json_encode|escape('html_attr') }}" data-iv="{{ storedObject.iv|json_encode|escape('html_attr') }}" data-temp-url-get-generator="{{ storedObject|generate_url|escape('html_attr') }}" data-mime-type="{{ storedObject.type|escape('html_attr') }}" {% if filename is not null %}data-filename="{{ filename|escape('html_attr') }}"{% endif %}>{{ 'Download'|trans }}</a>
|
{% if storedObject is null %}
|
||||||
|
<!-- No document to download -->
|
||||||
|
{% else %}
|
||||||
|
<a class="sc-button bt-download" data-label-preparing="{{ ('Preparing'|trans ~ '...')|escape('html_attr') }}" data-label-ready="{{ 'Ready to show'|trans|escape('html_attr') }}" data-download-button data-key="{{ storedObject.keyInfos|json_encode|escape('html_attr') }}" data-iv="{{ storedObject.iv|json_encode|escape('html_attr') }}" data-temp-url-get-generator="{{ storedObject|generate_url|escape('html_attr') }}" data-mime-type="{{ storedObject.type|escape('html_attr') }}" {% if filename is not null %}data-filename="{{ filename|escape('html_attr') }}"{% endif %}>{{ 'Download'|trans }}</a>
|
||||||
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user