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

Method createFromDataFile

lib/Service/ReportService.php:260–285  ·  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

258 * @return int ID of the newly created report
259 */
260 public function createFromDataFile($file = '') {
261 $this->ActivityManager->triggerEvent(0, ActivityManager::OBJECT_REPORT, ActivityManager::SUBJECT_REPORT_ADD);
262
263 $reportId = 0;
264
265 if ($file !== '') {
266 if (is_numeric($file)) {
267 $userFolder = $this->rootFolder->getUserFolder($this->userId);
268 $nodes = $userFolder->getById((int)$file);
269 if (isset($nodes[0])) {
270 $file = $userFolder->getRelativePath($nodes[0]->getPath());
271 }
272 }
273
274 $name = explode('.', end(explode('/', $file)))[0];
275 $subheader = $file;
276 $parent = 0;
277 $dataset = 0;
278 $type = DatasourceController::DATASET_TYPE_LOCAL_CSV;
279 $link = $file;
280 $visualization = 'table';
281 $chart = 'line';
282 $reportId = $this->ReportMapper->create($name, $subheader, $parent, $type, $dataset, $link, $visualization, $chart, '', '', '');
283 }
284 return $reportId;
285 }
286
287 /**
288 * 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