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

Method create

lib/Service/ReportService.php:205–244  ·  view source on GitHub ↗

* create new blank report * * @return int * @throws Exception */

(
		$name,
		$subheader,
		$parent,
		$type,
		int $dataset,
		$link,
		$visualization,
		$chart,
		$dimension1,
		$dimension2,
		$value,
		$addReport = null
	)

Source from the content-addressed store, hash-verified

203 * @throws Exception
204 */
205 public function create(
206 $name,
207 $subheader,
208 $parent,
209 $type,
210 int $dataset,
211 $link,
212 $visualization,
213 $chart,
214 $dimension1,
215 $dimension2,
216 $value,
217 $addReport = null
218 ): int {
219 if ($type === DatasourceController::DATASET_TYPE_GROUP) {
220 $parent = 0;
221 }
222 if (!$this->isValidParent((int)$parent)) {
223 return 0;
224 }
225 if ($dataset < 0 || ($type !== DatasourceController::DATASET_TYPE_INTERNAL_DB && $dataset !== 0)) {
226 return 0;
227 }
228 $link = $this->datasourceController->encodeOptionsForStorage((int)$type, $link);
229 if ($type === DatasourceController::DATASET_TYPE_INTERNAL_DB && $dataset === 0) { // New dataset
230 $dataset = $this->DatasetService->create($name, $dimension1, $dimension2, $value);
231 } else if ($type === DatasourceController::DATASET_TYPE_INTERNAL_DB && $dataset !== 0) {
232 $ownDataset = $this->DatasetService->readOwn($dataset);
233 if (empty($ownDataset)) {
234 return 0;
235 }
236 }
237 $reportId = $this->ReportMapper->create($name, $subheader, $parent, $type, $dataset, $link, $visualization, $chart, $dimension1, $dimension2, $value);
238 $this->ActivityManager->triggerEvent($reportId, ActivityManager::OBJECT_REPORT, ActivityManager::SUBJECT_REPORT_ADD);
239
240 if ($addReport !== null && $addReport !== '') {
241 $this->updateGroup($addReport, $reportId);
242 }
243 return $reportId;
244 }
245
246 /**
247 * copy an existing report with the current navigation status

Callers 3

importMethod · 0.95
createCopyMethod · 0.45
createFromDataFileMethod · 0.45

Calls 5

isValidParentMethod · 0.95
updateGroupMethod · 0.95
triggerEventMethod · 0.80
readOwnMethod · 0.45

Tested by

no test coverage detected