คุณสามารถใช้ hook_views_pre_execute (& $ view) เพื่อขยายเงื่อนไขเดียวของคุณไปยังหลาย ๆ ฟิลด์ที่คุณต้องการ
/**
* Recursive looks for mentioning of $fname as field of in query QueryConditionInterface::conditions()
*
* @param array $cond result of QueryConditionInterface::conditions to search in
* @param string $fname a name oof field we are looking for
* @param array $res result array containing a references of conditions having $fname
* @param integer $rec_lvl level of recursion
*
* @return array an array containing $fname mentioned in condition $res[]['field'] == $fname
*/
function dolynskyi_help_func_find_field_condition(&$cond, $fname, &$res = array(), &$rec_lvl = 0) {
$numeric_keys = array_filter(array_keys($cond), function($k) {return is_int($k) || (substr($k, 0, 1) !== '#');});
$rec_lvl++;
foreach($numeric_keys as $numkey) {
$t = gettype($cond[$numkey]['field']);
if($t == 'string') {
if($cond[$numkey]['field'] == $fname) {
$res[] = &$cond[$numkey];
}
} elseif($t == 'object') {
dolynskyi_help_func_find_field_condition($cond[$numkey]['field']->conditions(), $fname, $res, $rec_lvl);
}
}
$rec_lvl--;
return $res;
}
function dolynskyi_help_func_views_pre_execute(&$view) {
if($view->name == 'appraisals_special_global_access') { // view name we wanna extend
$fname = 'field_data_field_ap2_employee.field_ap2_employee_target_id'; // field we look for to use as source of extending
$search = &dolynskyi_help_func_find_field_condition($view->build_info['query']->conditions(), $fname);
foreach($search as &$v) { // looping found field references
$or = db_or();
$or->condition($v['field'], $v['value'], $v['operator']); //repeating existing field condition
$or->condition('field_data_field_ap2_employee.field_ap2_employee_target_id', array('711'), 'IN'); //adding any extra condition
$v = array('value'=>null, 'operator'=>'IS NULL', 'field'=>$or); // wrapping up simple condition for $fname to multiple with $fname + our extra field via OR logic
unset($v);
}
}
}