d8views.views_execution.inc 774 Bytes
Newer Older
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
<?php

function d8views_views_query_alter(Drupal\views\ViewExecutable $view, Drupal\views\Plugin\views\query\Sql $query) {
if ($view->id() == 'test1') {
 
    foreach ($query->where as &$condition_group) {
      foreach ($condition_group['conditions'] as &$condition) {
        
        if ($condition['field'] == 'school_entity_aitisi_entity.iekcode') {

          $user = \Drupal::service('current_user');
          $uid = $user->id();
          //$formatted_name = $user->getDisplayName();
          $raw_name = $user->getAccountName();
          //$raw_name = 'admin';

          $condition = array(
            'field' => 'school_entity_aitisi_entity.iekcode',
            'value' => $raw_name,
            'operator' => '=',
          );
        }
      }
    }
  }

}