public function getFarm($farmId, $modify = false)
{
/* @var $farm Farm */
$farm = Farm::findPk($farmId);
if (!$farm) {
throw new ApiErrorException(404, ErrorMessage::ERR_OBJECT_NOT_FOUND, "Requested Farm either does not exist or is not owned by your environment.");
}
if (!$this->hasPermissions($farm, $modify)) {
//Checks entity level write access permissions
throw new ApiErrorException(403, ErrorMessage::ERR_PERMISSION_VIOLATION, "Insufficient permissions");
}
return $farm;
}