mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 23:53:50 +00:00
Fix tests on ExportManager
This commit is contained in:
@@ -456,11 +456,11 @@ class ExportManager
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function isGrantedForElement(ExportElementInterface $element, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export = null, ?array $centers = null): bool
|
||||
public function isGrantedForElement(ExportInterface|DirectExportInterface|ModifierInterface $element, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export = null, ?array $centers = null): bool
|
||||
{
|
||||
if ($element instanceof ExportInterface || $element instanceof DirectExportInterface) {
|
||||
$role = $element->requiredRole();
|
||||
} elseif ($element instanceof ModifierInterface) {
|
||||
} else {
|
||||
if (null === $element->addRole()) {
|
||||
if (null === $export) {
|
||||
throw new LogicException('The export should not be null: as the '
|
||||
@@ -471,13 +471,10 @@ class ExportManager
|
||||
} else {
|
||||
$role = $element->addRole();
|
||||
}
|
||||
} else {
|
||||
throw new LogicException('The element is not an ModifiersInterface or '
|
||||
. 'an ExportInterface.');
|
||||
}
|
||||
|
||||
if (null === $centers || [] !== $centers) {
|
||||
// we want to try if at least one center is reachabler
|
||||
if (null === $centers || [] === $centers) {
|
||||
// we want to try if at least one center is reachable
|
||||
return [] !== $this->authorizationHelper->getReachableCenters(
|
||||
$this->user,
|
||||
$role
|
||||
@@ -542,6 +539,11 @@ class ExportManager
|
||||
$aggregators = $this->retrieveUsedAggregators($data);
|
||||
|
||||
foreach ($aggregators as $alias => $aggregator) {
|
||||
if ($this->isGrantedForElement($aggregator, $export, $center) === false) {
|
||||
throw new UnauthorizedHttpException('You are not authorized to '
|
||||
. 'use the aggregator' . $aggregator->getTitle());
|
||||
}
|
||||
|
||||
$formData = $data[$alias];
|
||||
$aggregator->alterQuery($qb, $formData['form']);
|
||||
}
|
||||
|
Reference in New Issue
Block a user