function farm_plan_plugin_argument_validate_farm_plan::validate_argument in farmOS 7
Overrides views_plugin_argument_validate::validate_argument
File
- modules/
farm/ farm_plan/ views/ plugins/ farm_plan_plugin_argument_validate_farm_plan.inc, line 39 - Contains the 'farm plan' argument validator plugin.
Class
- farm_plan_plugin_argument_validate_farm_plan
- Validate whether an argument is an acceptable farm_plan entity.
Code
function validate_argument($argument) {
// If the argument is not a number, fail.
if (!is_numeric($argument)) {
return FALSE;
}
// Attempt to load the farm plan entity.
$farm_plan = farm_plan_load($argument);
// If the plan didn't load, fail.
if (empty($farm_plan)) {
return FALSE;
}
// Set the validated title.
$this->argument->validated_title = check_plain(entity_label('farm_plan', $farm_plan));
// Load the valid plan types from options, and return TRUE if the list is
// empty, or if the type is in the list.
$types = array_filter($this->options['types']);
return empty($types) || !empty($types[$farm_plan->type]);
}