MCPcopy Create free account
hub / github.com/Rello/analytics / createCopy

Method createCopy

lib/Service/ReportService.php:227–242  ·  view source on GitHub ↗

* copy an existing report with the current navigation status * * @NoAdminRequired * @param int $reportId * @param $chartoptions * @param $dataoptions * @param $filteroptions * @return int * @throws Exception */

(int $reportId, $chartoptions, $dataoptions, $filteroptions, $tableoptions)

Source from the content-addressed store, hash-verified

225 * @throws Exception
226 */
227 public function createCopy(int $reportId, $chartoptions, $dataoptions, $filteroptions, $tableoptions) {
228
229 $template = $this->ReportMapper->readOwn($reportId);
230 $newId = $this->ReportMapper->create(// TRANSLATORS Noun
231 $template['name'] . ' - ' . $this->l10n->t('copy'), $template['subheader'], $template['parent'], $template['type'], $template['dataset'], $template['link'], $template['visualization'], $template['chart'], $template['dimension1'], $template['dimension2'], $template['value']);
232 $this->ReportMapper->updateOptions($newId, $chartoptions, $dataoptions, $filteroptions, $tableoptions);
233
234 // Copy thresholds from original report to the new copy
235 $sourceThresholds = $this->ThresholdMapper->getThresholdsByReport($reportId);
236 foreach ($sourceThresholds as $threshold) {
237 $this->ThresholdMapper->create($newId, $threshold['dimension'], $threshold['value'], // This is 'target' aliased as 'value' in the query
238 $threshold['option'], $threshold['severity'], $threshold['coloring']);
239 }
240
241 return $newId;
242 }
243
244 /**
245 * create new report

Callers

nothing calls this directly

Calls 5

getThresholdsByReportMethod · 0.80
readOwnMethod · 0.45
createMethod · 0.45
tMethod · 0.45
updateOptionsMethod · 0.45

Tested by

no test coverage detected