function opigno_certificate_install in Opigno certificate 3.x
Same name and namespace in other branches
- 8 opigno_certificate.install \opigno_certificate_install()
Implements hook_install().
File
- ./
opigno_certificate.install, line 15 - Install, update and uninstall functions for the Opigno Certificate module.
Code
function opigno_certificate_install() {
// Create default certificate.
$certificate = OpignoCertificate::create([
'bundle' => 'template',
'label' => t('Default certificate'),
]);
$certificate
->save();
// Allow platform-level content managers to administer certificates.
try {
$role = Role::load('content_manager');
$role
->grantPermission('administer certificates');
$role
->grantPermission('add certificate entities');
$role
->grantPermission('delete certificate entities');
$role
->grantPermission('edit certificate entities');
$role
->grantPermission('access certificate overview');
$role
->grantPermission('view published certificate entities');
$role
->grantPermission('view unpublished certificate entities');
$role
->save();
} catch (EntityStorageException $e) {
watchdog_exception('opigno_certificate_exception', $e);
}
// Enable CKEditor Background module.
\Drupal::service('module_installer')
->install([
'ckeditor_bgimage',
'ckeditor_font',
]);
}