function Sql::init

Same name in this branch
  1. 9 core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::init()
Same name in other branches
  1. 8.9.x core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::init()
  2. 8.9.x core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::init()
  3. 10 core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::init()
  4. 10 core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::init()
  5. 11.x core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::init()
  6. 11.x core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::init()

Overrides PluginBase::init

File

core/modules/views/src/Plugin/views/query/Sql.php, line 182

Class

Sql
Views query plugin for an SQL query.

Namespace

Drupal\views\Plugin\views\query

Code

public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    parent::init($view, $display, $options);
    $base_table = $this->view->storage
        ->get('base_table');
    $base_field = $this->view->storage
        ->get('base_field');
    $this->relationships[$base_table] = [
        'link' => NULL,
        'table' => $base_table,
        'alias' => $base_table,
        'base' => $base_table,
    ];
    // init the table queue with our primary table.
    $this->tableQueue[$base_table] = [
        'alias' => $base_table,
        'table' => $base_table,
        'relationship' => $base_table,
        'join' => NULL,
    ];
    // init the tables with our primary table
    $this->tables[$base_table][$base_table] = [
        'count' => 1,
        'alias' => $base_table,
    ];
    $this->count_field = [
        'table' => $base_table,
        'field' => $base_field,
        'alias' => $base_field,
        'count' => TRUE,
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.