mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 13:03:50 +00:00
Allow to group exports
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
16
Export/GroupedExportInterface.php
Normal file
16
Export/GroupedExportInterface.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
*/
|
||||
namespace Chill\MainBundle\Export;
|
||||
|
||||
/**
|
||||
* Add a grouping option to exports.
|
||||
*
|
||||
* **usage**: the exports will be grouped under the key given by the `getGroup`
|
||||
* method.
|
||||
*/
|
||||
interface GroupedExportInterface
|
||||
{
|
||||
public function getGroup(): string;
|
||||
}
|
Reference in New Issue
Block a user