mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Merge branch 'master' into PHRAS-2785_facets_on_date_restitued_in_wicked_way
This commit is contained in:
@@ -42,7 +42,7 @@ class ThesaurusHydrator implements HydratorInterface
|
||||
$fields = [];
|
||||
$index_fields = [];
|
||||
foreach ($structure as $name => $field) {
|
||||
$fields[$name] = $field->getThesaurusRoots();
|
||||
$fields[$name] = $field; // ->getThesaurusRoots();
|
||||
$index_fields[$name] = $field->getIndexField();
|
||||
}
|
||||
// Hydrate records with concepts
|
||||
@@ -51,7 +51,13 @@ class ThesaurusHydrator implements HydratorInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function hydrate(array &$record, array $fields, array $index_fields)
|
||||
/**
|
||||
* @param array $record
|
||||
* @param Field[] $fields
|
||||
* @param array $index_fields
|
||||
* @throws Exception
|
||||
*/
|
||||
private function hydrate(array &$record, $fields, array $index_fields)
|
||||
{
|
||||
if (!isset($record['databox_id'])) {
|
||||
throw new Exception('Expected a record with the "databox_id" key set.');
|
||||
@@ -61,7 +67,8 @@ class ThesaurusHydrator implements HydratorInterface
|
||||
$terms = array();
|
||||
$filters = array();
|
||||
$field_names = array();
|
||||
foreach ($fields as $name => $root_concepts) {
|
||||
foreach ($fields as $name => $field) {
|
||||
$root_concepts = $field->getThesaurusRoots();
|
||||
// Loop through all values to prepare bulk query
|
||||
$field_values = \igorw\get_in($record, explode('.', $index_fields[$name]));
|
||||
if ($field_values !== null) {
|
||||
@@ -84,13 +91,17 @@ class ThesaurusHydrator implements HydratorInterface
|
||||
$bulk = $this->thesaurus->findConceptsBulk($terms, null, $filters, true);
|
||||
|
||||
foreach ($bulk as $offset => $item_concepts) {
|
||||
$name = $field_names[$offset];
|
||||
if ($item_concepts && is_array($item_concepts) && count($item_concepts)>0) {
|
||||
$name = $field_names[$offset];
|
||||
foreach ($item_concepts as $concept) {
|
||||
$record['concept_path'][$name][] = $concept->getPath();
|
||||
}
|
||||
} else {
|
||||
$this->candidate_terms->insert($field_names[$offset], $values[$offset]);
|
||||
}
|
||||
else {
|
||||
$field = $fields[$name];
|
||||
if($field->get_generate_cterms()) {
|
||||
$this->candidate_terms->insert($field_names[$offset], $values[$offset]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ class Field implements Typed
|
||||
|
||||
private $thesaurus_roots;
|
||||
|
||||
private $generate_cterms;
|
||||
|
||||
private $used_by_collections;
|
||||
|
||||
public static function createFromLegacyField(databox_field $field, $with = Structure::WITH_EVERYTHING)
|
||||
@@ -75,6 +77,7 @@ class Field implements Typed
|
||||
'private' => $field->isBusiness(),
|
||||
'facet' => $facet,
|
||||
'thesaurus_roots' => $roots,
|
||||
'generate_cterms' => $field->get_generate_cterms(),
|
||||
'used_by_collections' => $databox->get_collection_unique_ids()
|
||||
]);
|
||||
}
|
||||
@@ -103,6 +106,7 @@ class Field implements Typed
|
||||
$this->is_private = \igorw\get_in($options, ['private'], false);
|
||||
$this->facet = \igorw\get_in($options, ['facet']);
|
||||
$this->thesaurus_roots = \igorw\get_in($options, ['thesaurus_roots'], null);
|
||||
$this->generate_cterms = \igorw\get_in($options, ['generate_cterms'], false);
|
||||
$this->used_by_collections = \igorw\get_in($options, ['used_by_collections'], []);
|
||||
|
||||
Assertion::boolean($this->is_searchable);
|
||||
@@ -126,6 +130,7 @@ class Field implements Typed
|
||||
'private' => $this->is_private,
|
||||
'facet' => $this->facet,
|
||||
'thesaurus_roots' => $this->thesaurus_roots,
|
||||
'generate_cterms' => $this->generate_cterms,
|
||||
'used_by_collections' => $this->used_by_collections
|
||||
]);
|
||||
}
|
||||
@@ -190,6 +195,11 @@ class Field implements Typed
|
||||
return $this->thesaurus_roots;
|
||||
}
|
||||
|
||||
public function get_generate_cterms()
|
||||
{
|
||||
return $this->generate_cterms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge with another field, returning the new instance
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user