function tabledrag_example_install

Same name in other branches
  1. 3.x modules/tabledrag_example/tabledrag_example.install \tabledrag_example_install()
  2. 7.x-1.x tabledrag_example/tabledrag_example.install \tabledrag_example_install()

Implements hook_install().

Populates newly created database table with fixtures for all module's examples. This hook executed after hook_schema() tables are created by core.

See also

\Drupal\Core\Extension\ModuleInstaller::install()

Related topics

File

modules/tabledrag_example/tabledrag_example.install, line 82

Code

function tabledrag_example_install() {
    
    /** @var \Drupal\Core\Database\Connection $connection */
    $connection = \Drupal::database();
    $rows = Fixtures::getSampleItems();
    foreach ($rows as $row) {
        $connection->insert('tabledrag_example')
            ->fields($row)
            ->execute();
    }
}