diff --git a/lib/Alchemy/Phrasea/Model/Entities/ElasticsearchRecord.php b/lib/Alchemy/Phrasea/Model/Entities/ElasticsearchRecord.php
index 0b5f3c4617..6733c89c8d 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/ElasticsearchRecord.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/ElasticsearchRecord.php
@@ -11,9 +11,8 @@
namespace Alchemy\Phrasea\Model\Entities;
-use Doctrine\Common\Collections\ArrayCollection;
-use Alchemy\Phrasea\Model\RecordInterface;
use Alchemy\Phrasea\Model\MutableRecordInterface;
+use Alchemy\Phrasea\Model\RecordInterface;
/**
* Record entity from elastic search
@@ -26,7 +25,7 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface
private $baseId;
private $collectionName;
private $mimeType;
- private $title;
+ private $title = [];
private $originalName;
private $updated;
private $created;
@@ -36,16 +35,11 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface
private $type;
private $status;
private $isStory;
- /** @var ArrayCollection */
- private $caption;
- /** @var ArrayCollection */
- private $exif;
- /** @var ArrayCollection */
- private $subdefs;
- /** @var ArrayCollection */
- private $flags;
- /** @var ArrayCollection */
- private $highlight;
+ private $caption = [];
+ private $exif = [];
+ private $subdefs = [];
+ private $flags = [];
+ private $highlight = [];
/** {@inheritdoc} */
public function getId()
@@ -110,7 +104,7 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface
/** {@inheritdoc} */
public function setIsStory($isStory)
{
- $this->isStory = (bool) $isStory;
+ $this->isStory = (bool)$isStory;
}
/** {@inheritdoc} */
@@ -187,12 +181,12 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface
*/
public function getTitle($locale = null)
{
- if ($locale && $this->title->containsKey($locale)) {
- return $this->title->get($locale);
+ if ($locale && isset($this->title[$locale])) {
+ return $this->title[$locale];
}
- if ($this->title->containsKey('default')) {
- return $this->title->get('default');
+ if (isset($this->title['default'])) {
+ return $this->title['default'];
}
return $this->getOriginalName();
@@ -201,9 +195,9 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface
/**
* Sets a collection of titles
*
- * @param ArrayCollection $titles
+ * @param string[] $titles
*/
- public function setTitles(ArrayCollection $titles)
+ public function setTitles(array $titles)
{
$this->title = $titles;
}
@@ -242,45 +236,41 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface
$this->uuid = $uuid;
}
- /** @return ArrayCollection */
+ /** @return array */
public function getCaption()
{
return $this->caption;
}
- public function setCaption(ArrayCollection $caption)
+ public function setCaption(array $caption)
{
$this->caption = $caption;
}
- /** @return ArrayCollection */
+ /** @return array */
public function getExif()
{
return $this->exif;
}
- /**
- * @param mixed $exif
- */
- public function setExif(ArrayCollection $exif)
+ public function setExif(array $exif)
{
$this->exif = $exif;
}
- /** @return ArrayCollection */
+ /** @return array */
public function getSubdefs()
{
return $this->subdefs;
}
- /** @return ArrayCollection */
- public function setSubdefs(ArrayCollection $subdefs)
+ public function setSubdefs(array $subdefs)
{
$this->subdefs = $subdefs;
}
/**
- * @return ArrayCollection
+ * @return array
*/
public function getFlags()
{
@@ -288,9 +278,9 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface
}
/**
- * @param ArrayCollection $flags
+ * @param array $flags
*/
- public function setFlags(ArrayCollection $flags)
+ public function setFlags(array $flags)
{
$this->flags = $flags;
}
@@ -323,7 +313,7 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface
}
/**
- * @return ArrayCollection
+ * @return array
*/
public function getHighlight()
{
@@ -331,9 +321,9 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface
}
/**
- * @param ArrayCollection $highlight
+ * @param array $highlight
*/
- public function setHighlight(ArrayCollection $highlight)
+ public function setHighlight(array $highlight)
{
$this->highlight = $highlight;
}
diff --git a/lib/Alchemy/Phrasea/Model/RecordInterface.php b/lib/Alchemy/Phrasea/Model/RecordInterface.php
index 5907d60d34..c542b5afc3 100644
--- a/lib/Alchemy/Phrasea/Model/RecordInterface.php
+++ b/lib/Alchemy/Phrasea/Model/RecordInterface.php
@@ -58,9 +58,9 @@ interface RecordInterface
/** @return integer */
public function getStatusBitField();
- /** @return ArrayCollection */
+ /** @return array */
public function getExif();
- /** @return ArrayCollection */
+ /** @return array */
public function getCaption();
}
diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php
index 7f553439bf..33f1038b56 100644
--- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php
+++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php
@@ -41,12 +41,12 @@ class ElasticsearchRecordHydrator
$record->setUpdated($updatedOn ? new \DateTime($updatedOn) : $updatedOn);
$record->setUuid(igorw\get_in($data, ['uuid'], ''));
$record->setStatusBitField(igorw\get_in($data, ['flags_bitfield'], 0));
- $record->setTitles(new ArrayCollection((array) igorw\get_in($data, ['title'], [])));
- $record->setCaption(new ArrayCollection((array) igorw\get_in($data, ['caption'], [])));
- $record->setExif(new ArrayCollection((array) igorw\get_in($data, ['exif'], [])));
- $record->setSubdefs(new ArrayCollection((array) igorw\get_in($data, ['subdefs'], [])));
- $record->setFlags(new ArrayCollection((array) igorw\get_in($data, ['flags'], [])));
- $record->setHighlight(new ArrayCollection($highlight));
+ $record->setTitles((array) igorw\get_in($data, ['title'], []));
+ $record->setCaption((array) igorw\get_in($data, ['caption'], []));
+ $record->setExif((array) igorw\get_in($data, ['exif'], []));
+ $record->setSubdefs((array) igorw\get_in($data, ['subdefs'], []));
+ $record->setFlags((array) igorw\get_in($data, ['flags'], []));
+ $record->setHighlight((array) $highlight);
return $record;
}
diff --git a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php
index 8c2fbacbf6..f3f68d1f01 100644
--- a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php
+++ b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php
@@ -2,10 +2,10 @@
namespace Alchemy\Phrasea\Twig;
+use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\ElasticsearchRecord;
use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\RecordInterface;
-use Silex\Application;
class PhraseanetExtension extends \Twig_Extension
{
@@ -49,11 +49,12 @@ class PhraseanetExtension extends \Twig_Extension
if ($record instanceof ElasticsearchRecord) {
$highlightKey = sprintf('caption.%s', $field);
- if (false === $record->getHighlight()->containsKey($highlightKey)) {
+ $highlights = $record->getHighlight();
+ if (false === isset($highlights[$highlightKey])) {
return implode('; ', (array) $value);
}
- $highlightValue = $record->getHighlight()->get($highlightKey);
+ $highlightValue = $highlights[$highlightKey];
// if field is multivalued, merge highlighted values with captions ones
if (is_array($value)) {
@@ -71,7 +72,9 @@ class PhraseanetExtension extends \Twig_Extension
public function getRecordFlags(RecordInterface $record)
{
$recordStatuses = [];
- $databox = $this->app['phraseanet.appbox']->get_databox($record->getDataboxId());
+ /** @var \appbox $appbox */
+ $appbox = $this->app['phraseanet.appbox'];
+ $databox = $appbox->get_databox($record->getDataboxId());
$structure = $databox->getStatusStructure()->toArray();
@@ -207,8 +210,9 @@ class PhraseanetExtension extends \Twig_Extension
public function getSubdefUrl(RecordInterface $record, $subdefName)
{
if ($record instanceof ElasticsearchRecord) {
- if ($record->getSubdefs()->containsKey($subdefName)) {
- $thumbnail = $record->getSubdefs()->get($subdefName);
+ $subdefs = $record->getSubdefs();
+ if (isset($subdefs[$subdefName])) {
+ $thumbnail = $subdefs[$subdefName];
if (null !== $path = $thumbnail['path']) {
if (is_string($path) && '' !== $path) {
return $this->app['phraseanet.static-file']->getUrl($path);
diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php
index cbd592b924..054449bf1e 100644
--- a/lib/classes/record/adapter.php
+++ b/lib/classes/record/adapter.php
@@ -765,14 +765,15 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
public function getCaption()
{
- $collection = new ArrayCollection();
+ $collection = [];
+ /** @var caption_field $field */
foreach ($this->get_caption()->get_fields() as $field) {
- $values = array_map(function($fieldValue) {
+ $values = array_map(function(caption_Field_Value $fieldValue) {
return $fieldValue->getValue();
}, $field->get_values());
- $collection->set($field->get_name(), $values);
+ $collection[$field->get_name()] = $values;
}
return $collection;
@@ -2035,7 +2036,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
/** {@inheritdoc} */
public function getExif()
{
- return new ArrayCollection($this->get_technical_infos());
+ return $this->get_technical_infos();
}
public function getStatusStructure()
diff --git a/templates/web/common/technical_datas.html.twig b/templates/web/common/technical_datas.html.twig
index 64b9de9412..b01978ac16 100644
--- a/templates/web/common/technical_datas.html.twig
+++ b/templates/web/common/technical_datas.html.twig
@@ -19,52 +19,52 @@
{% block td_size %}
- {% set width = record.exif.get(constant('media_subdef::TC_DATA_WIDTH')) %}
- {% set height = record.exif.get(constant('media_subdef::TC_DATA_HEIGHT')) %}
+ {% set width = record.exif[constant('media_subdef::TC_DATA_WIDTH')]|default(null) %}
+ {% set height = record.exif[constant('media_subdef::TC_DATA_HEIGHT')]|default(null) %}
{% if width is not none and height is not none %}
{{ width ~ " x " ~ height }}
{% endif %}
{% endblock %}