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

Method createFromDataFile

lib/Service/ReportService.php:293–318  ·  view source on GitHub ↗

* create new report * * @param string $file * @return int */ * Create a report based on a data file. * * @param int|string $file Path to the file or the numeric file ID * * @return int ID of the newly created report */

($file = '')

Source from the content-addressed store, hash-verified

291 * @return int ID of the newly created report
292 */
293 public function createFromDataFile($file = '') {
294 $this->ActivityManager->triggerEvent(0, ActivityManager::OBJECT_REPORT, ActivityManager::SUBJECT_REPORT_ADD);
295
296 $reportId = 0;
297
298 if ($file !== '') {
299 if (is_numeric($file)) {
300 $userFolder = $this->rootFolder->getUserFolder($this->userId);
301 $nodes = $userFolder->getById((int)$file);
302 if (isset($nodes[0])) {
303 $file = $userFolder->getRelativePath($nodes[0]->getPath());
304 }
305 }
306
307 $name = explode('.', end(explode('/', $file)))[0];
308 $subheader = $file;
309 $parent = 0;
310 $dataset = 0;
311 $type = DatasourceController::DATASET_TYPE_LOCAL_CSV;
312 $link = $file;
313 $visualization = 'table';
314 $chart = 'line';
315 $reportId = $this->ReportMapper->create($name, $subheader, $parent, $type, $dataset, $link, $visualization, $chart, '', '', '');
316 }
317 return $reportId;
318 }
319
320 /**
321 * update report details

Callers

nothing calls this directly

Calls 3

triggerEventMethod · 0.80
getUserFolderMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected