exports: display group as a breadcrumb in template

add a private method in controller which could be moved maybe in ExportManager
This commit is contained in:
2022-08-17 13:02:54 +02:00
parent d9b668e614
commit df9a5071c7
5 changed files with 43 additions and 1 deletions

View File

@@ -86,6 +86,9 @@ class ExportController extends AbstractController
{
/** @var \Chill\MainBundle\Export\ExportManager $exportManager */
$exportManager = $this->exportManager;
$export = $exportManager->getExport($alias);
$key = $request->query->get('key', null);
[$dataCenters, $dataExport, $dataFormatter] = $this->rebuildData($key);
@@ -100,7 +103,8 @@ class ExportController extends AbstractController
$viewVariables = [
'alias' => $alias,
'export' => $exportManager->getExport($alias),
'export' => $export,
'export_group' => $this->getExportGroup($export),
];
if ($formater instanceof \Chill\MainBundle\Export\Formatter\CSVListFormatter) {
@@ -316,6 +320,7 @@ class ExportController extends AbstractController
'form' => $form->createView(),
'export_alias' => $alias,
'export' => $export,
'export_group' => $this->getExportGroup($export),
]);
}
@@ -371,6 +376,7 @@ class ExportController extends AbstractController
[
'form' => $form->createView(),
'export' => $export,
'export_group' => $this->getExportGroup($export),
]
);
}
@@ -514,6 +520,7 @@ class ExportController extends AbstractController
[
'form' => $form->createView(),
'export' => $export,
'export_group' => $this->getExportGroup($export),
]
);
}
@@ -565,4 +572,19 @@ class ExportController extends AbstractController
throw new LogicException("the step {$step} is not defined.");
}
}
private function getExportGroup($target): string
{
$exportManager = $this->exportManager;
$groups = $exportManager->getExportsGrouped(true);
foreach ($groups as $group => $array) {
foreach ($array as $alias => $export) {
if ($export === $target) {
return $group;
}
}
}
}
}