diff --git a/Controller/ExportController.php b/Controller/ExportController.php index 22f3a0fe2..ec8d9ee7a 100644 --- a/Controller/ExportController.php +++ b/Controller/ExportController.php @@ -107,10 +107,10 @@ class ExportController extends Controller { $exportManager = $this->exportManager; - $exports = $exportManager->getExports(true); + $exports = $exportManager->getExportsGrouped(true); return $this->render('ChillMainBundle:Export:layout.html.twig', array( - 'exports' => $exports + 'grouped_exports' => $exports )); } diff --git a/Export/ExportManager.php b/Export/ExportManager.php index ea15fea63..89e5a6599 100644 --- a/Export/ExportManager.php +++ b/Export/ExportManager.php @@ -231,6 +231,26 @@ class ExportManager } } + /** + * Get all exports grouped in an array. + * + * @param bool $whereUserIsGranted + * @return array where keys are the groups's name and value is an array of exports + */ + public function getExportsGrouped($whereUserIsGranted = true): array + { + $groups = [ '_' => [] ]; + foreach ($this->getExports($whereUserIsGranted) as $alias => $export) { + if ($export instanceof GroupedExportInterface) { + $groups[$export->getGroup()][$alias] = $export; + } else { + $groups['_'][$alias] = $export; + } + } + + return $groups; + } + /** * Return an export by his alias * diff --git a/Export/GroupedExportInterface.php b/Export/GroupedExportInterface.php new file mode 100644 index 000000000..9330fd32b --- /dev/null +++ b/Export/GroupedExportInterface.php @@ -0,0 +1,16 @@ +
{{ export.description|trans }}
+{{ export.description|trans }}
- + +{{ export.description|trans }}
+ + +