function _views_query_tag_alter_condition
Same name in other branches
- 9 core/modules/views/views.module \_views_query_tag_alter_condition()
- 10 core/modules/views/views.module \_views_query_tag_alter_condition()
- 11.x core/modules/views/views.module \_views_query_tag_alter_condition()
Replaces the substitutions recursive foreach condition.
1 call to _views_query_tag_alter_condition()
- views_query_views_alter in core/
modules/ views/ views.module - Implements hook_query_TAG_alter().
File
-
core/
modules/ views/ views.module, line 690
Code
function _views_query_tag_alter_condition(AlterableInterface $query, &$conditions, $substitutions) {
foreach ($conditions as $condition_id => &$condition) {
if (is_numeric($condition_id)) {
if (is_string($condition['field'])) {
$condition['field'] = str_replace(array_keys($substitutions), array_values($substitutions), $condition['field']);
}
elseif (is_object($condition['field'])) {
$sub_conditions =& $condition['field']->conditions();
_views_query_tag_alter_condition($query, $sub_conditions, $substitutions);
}
// $condition['value'] is a subquery so alter the subquery recursive.
// Therefore make sure to get the metadata of the main query.
if (is_object($condition['value'])) {
$subquery = $condition['value'];
$subquery->addMetaData('views_substitutions', $query->getMetaData('views_substitutions'));
views_query_views_alter($condition['value']);
}
elseif (isset($condition['value'])) {
// We can not use a simple str_replace() here because it always returns
// a string and we have to keep the type of the condition value intact.
if (is_array($condition['value'])) {
foreach ($condition['value'] as &$value) {
if (is_string($value)) {
$value = str_replace(array_keys($substitutions), array_values($substitutions), $value);
}
}
}
elseif (is_string($condition['value'])) {
$condition['value'] = str_replace(array_keys($substitutions), array_values($substitutions), $condition['value']);
}
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.