* set/remove the favorite flag for a report * * @param int $reportId * @param string $favorite * @return bool */
(int $reportId, string $favorite)
| 399 | * @return bool |
| 400 | */ |
| 401 | public function setFavorite(int $reportId, string $favorite) { |
| 402 | $return = true; |
| 403 | if ($favorite === 'true') { |
| 404 | $return = $this->addFavoriteTag('analytics', $reportId); |
| 405 | } else { |
| 406 | $favorites = $this->tagManager->load('analytics')->getFavorites(); |
| 407 | if (is_array($favorites) and in_array($reportId, $favorites)) { |
| 408 | $return = $this->removeFavoriteTag('analytics', $reportId); |
| 409 | } |
| 410 | } |
| 411 | return $return; |
| 412 | } |
| 413 | |
| 414 | private function addFavoriteTag(string $scope, int $objectId): bool { |
| 415 | try { |