function tabledrag_example_install in Examples for Developers 8
Same name and namespace in other branches
- 7 tabledrag_example/tabledrag_example.install \tabledrag_example_install()
- 3.x modules/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
- tabledrag_example/
tabledrag_example.install, line 82 - Install and uninstall functions for the tabledrag example module.
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();
}
}