You are here

public function Table::__construct in Data 8

Constructor. Do not call directly, but use DataTable::instance($name) instead.

File

src/Table.php, line 45

Class

Table
Manages data access and manipulation for a single data table. Use data_create_table() or data_get_table() to instantiate an object from this class.

Namespace

Drupal\data

Code

public function __construct($name) {

  // Set our name after sanitizing it.
  $this->name = \Drupal::database()
    ->escapeTable($name);

  // Try to load table information.
  if ($table = _data_load_table($name)) {
    foreach (array(
      'title',
      'name',
      'table_schema',
      'meta',
      'export_type',
    ) as $key) {
      if (isset($table->{$key})) {
        $this->{$key} = $table->{$key};
      }
    }
  }
}