original_string: protected function _buildUnionPart($parts, $query, $generator)
      {
          $parts = array_map(function ($p) use ($generator) {
              $p['query'] = $p['query']->sql($generator);
              $p['query'] = $p['query'][0] === '(' ? trim($p['query'], '()') : $p['query'];
              $prefix = $p['all'] ? 'ALL ' : '';
              if ($this->_orderedUnion) {
                  return "{$prefix}({$p['query']})";
              }
  
              return $prefix . $p['query'];
          }, $parts);
  
          if ($this->_orderedUnion) {
              return sprintf(")\nUNION %s", implode("\nUNION ", $parts));
          }
  
          return sprintf("\nUNION %s", implode("\nUNION ", $parts));
      }
code: protected function _buildUnionPart($parts, $query, $generator)
      {
          $parts = array_map(function ($p) use ($generator) {
              $p['query'] = $p['query']->sql($generator);
              $p['query'] = $p['query'][0] === '(' ? trim($p['query'], '()') : $p['query'];
              $prefix = $p['all'] ? 'ALL ' : '';
              if ($this->_orderedUnion) {
                  return "{$prefix}({$p['query']})";
              }
  
              return $prefix . $p['query'];
          }, $parts);
  
          if ($this->_orderedUnion) {
              return sprintf(")\nUNION %s", implode("\nUNION ", $parts));
          }
  
          return sprintf("\nUNION %s", implode("\nUNION ", $parts));
      }
code_tokens: protected function _buildUnionPart ( $ parts , $ query , $ generator ) { $ parts = array_map ( function ( $ p ) use ( $ generator ) { $ p [ 'query' ] = $ p [ 'query' ] -> sql ( $ generator ) ; $ p [ 'query' ] = $ p [ 'query' ] [ 0 ] === '(' ? trim ( $ p [ 'query' ] , '()' ) : $ p [ 'query' ] ; $ prefix = $ p [ 'all' ] ? 'ALL ' : '' ; if ( $ this -> _orderedUnion ) { return "{$prefix}({$p['query']})" ; } return $ prefix . $ p [ 'query' ] ; } , $ parts ) ; if ( $ this -> _orderedUnion ) { return sprintf ( ")\nUNION %s" , implode ( "\nUNION " , $ parts ) ) ; } return sprintf ( "\nUNION %s" , implode ( "\nUNION " , $ parts ) ) ; }
docstring: Builds the SQL string for all the UNION clauses in this query, when dealing
  with query objects it will also transform them using their configured SQL
  dialect.
  
  @param array $parts list of queries to be operated with UNION
  @param \Cake\Database\Query $query The query that is being compiled
  @param \Cake\Database\ValueBinder $generator the placeholder generator to be used in expressions
  @return string
docstring_tokens: Builds the SQL string for all the UNION clauses in this query when dealing with query objects it will also transform them using their configured SQL dialect .