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

Method create

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

172 * @throws Exception
173 */
174 public function create(
175 $name,
176 $subheader,
177 $parent,
178 $type,
179 int $dataset,
180 $link,
181 $visualization,
182 $chart,
183 $dimension1,
184 $dimension2,
185 $value,
186 $addReport = null
187 ): int {
188 $array = json_decode($link, true);
189 if (is_array($array)) {
190 foreach ($array as $key => $value) {
191 $array[$key] = htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
192 }
193 }
194 $link = json_encode($array);
195
196 if ($type === DatasourceController::DATASET_TYPE_GROUP) {
197 $parent = 0;
198 }
199 if (!$this->isValidParent((int)$parent)) {
200 return 0;
201 }
202 if ($type === DatasourceController::DATASET_TYPE_INTERNAL_DB && $dataset === 0) { // New dataset
203 $dataset = $this->DatasetService->create($name, $dimension1, $dimension2, $value);
204 } else if ($type === DatasourceController::DATASET_TYPE_INTERNAL_DB && $dataset !== 0) {
205 $ownDataset = $this->DatasetService->readOwn($dataset);
206 if (empty($ownDataset)) {
207 return 0;
208 }
209 }
210 $reportId = $this->ReportMapper->create($name, $subheader, $parent, $type, $dataset, $link, $visualization, $chart, $dimension1, $dimension2, $value);
211 $this->ActivityManager->triggerEvent($reportId, ActivityManager::OBJECT_REPORT, ActivityManager::SUBJECT_REPORT_ADD);
212
213 if ($addReport !== null && $addReport !== '') {
214 $this->updateGroup($addReport, $reportId);
215 }
216 return $reportId;
217 }
218
219 /**
220 * copy an existing report with the current navigation status

Callers 3

importMethod · 0.95
createCopyMethod · 0.45
createFromDataFileMethod · 0.45

Calls 4

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

Tested by

no test coverage detected