public function getEvent($eventId, $restrictToCurrentScope = false)
{
$criteria = $this->getDefaultCriteria();
$criteria[] = ['name' => $eventId];
/* @var $event Entity\EventDefinition */
$event = Entity\EventDefinition::findOne($criteria);
$scopeName = ucfirst($this->getScope());
if (!$event) {
throw new ApiErrorException(404, ErrorMessage::ERR_OBJECT_NOT_FOUND, sprintf("The Event either does not exist or isn't in scope for the current %s.", $scopeName));
}
//To be over-suspicious check READ access to Event object
$this->checkPermissions($event);
if ($restrictToCurrentScope && ($event->getScope() !== $this->getScope() || $event->accountId !== $this->getUser()->accountId || $this->getEnvironment() && $event->envId !== $this->getEnvironment()->id)) {
throw new ApiErrorException(403, ErrorMessage::ERR_SCOPE_VIOLATION, sprintf("The Event is not either from the %s scope or owned by your %s.", $scopeName, $scopeName));
}
return $event;
}