*/ class Additional implements Loader { public function __construct( private Helper $helper, private EntityManager $entityManager, private ReportHelper $reportHelper ) {} /** * @throws Forbidden * @throws Error */ public function process(Entity $entity, Params $params): void { if ( $entity->get('reportType') === ReportEntity::TYPE_GRID && $entity->get('reportId') ) { /** @var ?ReportEntity $report */ $report = $this->entityManager->getEntityById(ReportEntity::ENTITY_TYPE, $entity->get('reportId')); if ($report) { $columnList = $report->getColumns(); $numericColumnList = []; $gridData = $this->reportHelper->fetchGridDataFromReport($report); foreach ($columnList as $column) { if ($this->helper->isColumnNumeric($column, $gridData)) { $numericColumnList[] = $column; } } if ( ( count($report->getGroupBy()) === 1 || count($report->getGroupBy()) === 0 ) && count($numericColumnList) > 1 ) { array_unshift($numericColumnList, ''); } $entity->set('columnList', $numericColumnList); } $entity->set('columnsData', $report->getColumnsData()); } $displayType = $entity->get('displayType'); $reportType = $entity->get('reportType'); $displayTotal = $entity->get('displayTotal'); $displayOnlyTotal = $entity->get('displayOnlyTotal'); if (!$displayType) { if ( $reportType === ReportEntity::TYPE_GRID || $reportType === ReportEntity::TYPE_JOINT_GRID ) { if ($displayOnlyTotal) { $displayType = 'Total'; } else if ($displayTotal) { $displayType = 'Chart-Total'; } else { $displayType = 'Chart'; } } else if ($reportType === ReportEntity::TYPE_LIST) { if ($displayOnlyTotal) { $displayType = 'Total'; } else { $displayType = 'List'; } } $entity->set('displayType', $displayType); } } }