public function modifyAction($imageId)
{
$this->checkScopedPermissions('IMAGES', 'MANAGE');
$object = $this->request->getJsonBody();
$imageAdapter = $this->adapter('image');
//Pre validates the request object
$imageAdapter->validateObject($object, Request::METHOD_PATCH);
if (isset($object->scope) && $object->scope !== $this->getScope()) {
throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, "Invalid scope");
}
//We have to do additional check instead of $this->checkPermissions() because we don't allow to modify SCALR level Image here
$image = $this->getImage($imageId, true);
//Copies all alterable properties to fetched Role Entity
$imageAdapter->copyAlterableProperties($object, $image);
//Re-validates an Entity
$imageAdapter->validateEntity($image);
//Saves verified results
$image->save();
return $this->result($imageAdapter->toData($image));
}