public function getCriterion(APILimitationValue $value, APIUserReference $currentUser)
{
if (empty($value->limitationValues)) {
// no limitation values
throw new \RuntimeException('$value->limitationValues is empty, it should not have been stored in the first place');
}
if ($value->limitationValues[0] != 1) {
throw new BadStateException('Parent User Group limitation', 'expected limitation value to be 1 but got:' . $value->limitationValues[0]);
}
$groupIds = array();
$currentUserLocations = $this->persistence->locationHandler()->loadLocationsByContent($currentUser->getUserId());
if (!empty($currentUserLocations)) {
foreach ($currentUserLocations as $currentUserLocation) {
$groupIds[] = $currentUserLocation->parentId;
}
}
return new Criterion\UserMetadata(Criterion\UserMetadata::GROUP, Criterion\Operator::IN, $groupIds);
}