isAttributeChanged('emailSendingInterval') || $entity->isAttributeChanged('emailSendingTime') || $entity->isAttributeChanged('emailSendingSettingWeekdays') || $entity->isAttributeChanged('emailSendingSettingDay') ) { /** @noinspection PhpRedundantOptionalArgumentInspection */ $entity->set('emailSendingLastDateSent', null); } if ( $entity->get('type') === ReportEntity::TYPE_GRID && ($entity->has('chartOneColumns') || $entity->has('chartOneY2Columns')) ) { $this->handleChartDataList($entity); } } private function handleChartDataList(Report $entity): void { $groupBy = $entity->getGroupBy(); if (count($groupBy) > 1) { /** @noinspection PhpRedundantOptionalArgumentInspection */ $entity->set('chartDataList', null); return; } $chartDataList = $entity->get('chartDataList'); $y = null; $y2 = null; if ($chartDataList && count($chartDataList) !== 0) { $y = $chartDataList[0]->columnList ?? null; $y2 = $chartDataList[0]->y2ColumnList ?? null; } $newY = $y ?? null; $newY2 = $y2 ?? null; if ($entity->has('chartOneColumns')) { $newY = $entity->get('chartOneColumns') ?? []; if ($newY && count($newY) === 0) { $newY = null; } } if ($entity->has('chartOneY2Columns')) { $newY2 = $entity->get('chartOneY2Columns') ?? []; if ($newY2 && count($newY2) === 0) { $newY2 = null; } } $chartType = $entity->get('chartType'); if (!in_array($chartType, ['BarVertical', 'BarHorizontal', 'Line'])) { $newY2 = null; } if ($newY || $newY2) { $newItem = (object) [ 'columnList' => $newY, 'y2ColumnList' => $newY2, ]; $entity->set('chartDataList', [$newItem]); return; } /** @noinspection PhpRedundantOptionalArgumentInspection */ $entity->set('chartDataList', null); } }