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

Method createFromDataFile

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

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