public Condition::compile($configs)
Compiles this conditional clause.
Parameters
$query: The query object this conditional clause belongs to.
Overrides ConditionInterface::compile
File
- core/lib/Drupal/Core/Config/Entity/Query/Condition.php, line 20
Class
- Condition
- Defines the condition class for the config entity query.
Namespace
Drupal\Core\Config\Entity\Query
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | public function compile( $configs ) { $and = strtoupper ( $this ->conjunction) == 'AND' ; $single_conditions = array (); $condition_groups = array (); foreach ( $this ->conditions as $condition ) { if ( $condition [ 'field' ] instanceof ConditionInterface) { $condition_groups [] = $condition ; } else { if (!isset( $condition [ 'operator' ])) { $condition [ 'operator' ] = is_array ( $condition [ 'value' ]) ? 'IN' : '=' ; } // Lowercase condition value(s) for case-insensitive matches. if ( is_array ( $condition [ 'value' ])) { $condition [ 'value' ] = array_map ( 'Drupal\Component\Utility\Unicode::strtolower' , $condition [ 'value' ]); } elseif (! is_bool ( $condition [ 'value' ])) { $condition [ 'value' ] = Unicode:: strtolower ( $condition [ 'value' ]); } $single_conditions [] = $condition ; } } $return = array (); if ( $single_conditions ) { foreach ( $configs as $config_name => $config ) { foreach ( $single_conditions as $condition ) { $match = $this ->matchArray( $condition , $config , explode ( '.' , $condition [ 'field' ])); // If AND and it's not matching, then the rest of conditions do not // matter and this config object does not match. // If OR and it is matching, then the rest of conditions do not // matter and this config object does match. if ( $and != $match ) { break ; } } if ( $match ) { $return [ $config_name ] = $config ; } } } elseif (! $condition_groups || $and ) { // If there were no single conditions then either: // - Complex conditions, OR: need to start from no entities. // - Complex conditions, AND: need to start from all entities. // - No complex conditions (AND/OR doesn't matter): need to return all // entities. $return = $configs ; } foreach ( $condition_groups as $condition ) { $group_entities = $condition [ 'field' ]->compile( $configs ); if ( $and ) { $return = array_intersect_key ( $return , $group_entities ); } else { $return = $return + $group_entities ; } } return $return ; } |
Please login to continue.