function workspace_install in Workspace 8
Same name and namespace in other branches
- 8.2 workspace.install \workspace_install()
Implementation of hook_install().
File
- ./
workspace.install, line 17 - Install, update and uninstall functions for the workspace module.
Code
function workspace_install() {
// Set workspace earlier to alter entities before anyone else does.
module_set_weight('workspace', 10);
// Add pointers for all existing workspaces.
foreach (Workspace::loadMultiple() as $workspace) {
\Drupal::service('workspace.entity_operations')
->workspaceInsert($workspace);
}
$default_workspace_id = \Drupal::getContainer()
->getParameter('workspace.default');
/** @var \Drupal\multiversion\Entity\WorkspaceInterface $stage */
$stage = Workspace::create([
'machine_name' => 'stage',
'label' => 'Stage',
'type' => 'basic',
]);
$stage
->set('upstream', $default_workspace_id);
$stage
->save();
// Allow workspace entity route alterations.
\Drupal::service('entity_type.manager')
->clearCachedDefinitions();
\Drupal::service('router.builder')
->rebuild();
}