public function getScopeCriteria($scope = null, $strictToScope = false)
{
switch ($scope ?: $this->getScope()) {
case ScopeInterface::SCOPE_ENVIRONMENT:
if ($strictToScope) {
$criteria = [['accountId' => $this->getUser()->accountId], ['envId' => $this->getEnvironment()->id]];
} else {
$criteria = [['$or' => [['accountId' => $this->getUser()->accountId], ['accountId' => null]]], ['$or' => [['envId' => $this->getEnvironment()->id], ['envId' => null]]]];
}
break;
case ScopeInterface::SCOPE_ACCOUNT:
if ($strictToScope) {
$criteria = [['accountId' => $this->getUser()->accountId], ['envId' => null]];
} else {
$criteria = [['$or' => [['accountId' => $this->getUser()->accountId], ['accountId' => null]]], ['envId' => null]];
}
break;
case ScopeInterface::SCOPE_SCALR:
$criteria = [['envId' => null], ['accountId' => null]];
break;
default:
throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, "Unexpected scope value");
}
return $criteria;
}