mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 05:53:13 +00:00
save facets following the order of the admin form.
This commit is contained in:
@@ -33,7 +33,19 @@ class SearchEngineController extends Controller
|
|||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
$this->saveElasticSearchOptions($form->getData());
|
/** @var ElasticsearchOptions $data */
|
||||||
|
$data = $form->getData();
|
||||||
|
// $q = $request->request->get('elasticsearch_settings');
|
||||||
|
$facetNames = []; // rebuild the data "_customValues/facets" list following the form order
|
||||||
|
foreach($request->request->get('elasticsearch_settings') as $name=>$value) {
|
||||||
|
$matches = null;
|
||||||
|
if(preg_match('/^facets:(.+):limit$/', $name, $matches) === 1) {
|
||||||
|
$facetNames[] = $matches[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data->reorderAggregableFields($facetNames);
|
||||||
|
|
||||||
|
$this->saveElasticSearchOptions($data);
|
||||||
|
|
||||||
return $this->app->redirectPath('admin_searchengine_form');
|
return $this->app->redirectPath('admin_searchengine_form');
|
||||||
}
|
}
|
||||||
|
@@ -257,6 +257,18 @@ class ElasticsearchOptions
|
|||||||
return $this->_customValues['facets'];
|
return $this->_customValues['facets'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set to change the facets order during admin/form save
|
||||||
|
public function reorderAggregableFields($facetNames)
|
||||||
|
{
|
||||||
|
$newFacets = [];
|
||||||
|
foreach ($facetNames as $name) {
|
||||||
|
if(($facet = $this->getAggregableField($name)) !== null) {
|
||||||
|
$newFacets[$name] = $facet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_customValues['facets'] = $newFacets;
|
||||||
|
}
|
||||||
|
|
||||||
public function getActiveTab()
|
public function getActiveTab()
|
||||||
{
|
{
|
||||||
return $this->activeTab;
|
return $this->activeTab;
|
||||||
|
Reference in New Issue
Block a user