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 @@ +

{{ 'Exports list'|trans }}

-
- {% for export_alias,export in exports %} -
-

{{ export.title|trans }}

-

{{ export.description|trans }}

+
+ {% for group, exports in grouped_exports if group != '_' %} +

{{ group }}

+ +
+ {% for export_alias, export in exports %} +
+

{{ export.title|trans }}

+

{{ export.description|trans }}

-

- - {{ 'Create an export'|trans }} - -

+

+ + {{ 'Create an export'|trans }} + +

+
+ {% endfor %} +
+ {% endfor %} + + {% if grouped_exports|keys|length > 1 %} +

{{ 'Ungrouped exports'|trans }}

+ {% endif %} + +
+ {% for export_alias,export in grouped_exports['_'] %} +
+

{{ export.title|trans }}

+

{{ export.description|trans }}

+ +

+ + {{ 'Create an export'|trans }} + +

+
+ {% endfor %} +
- {% endfor %} -
{% endblock %}