content_access.install in Content Access 8
Same filename and directory in other branches
Content access install file.
File
content_access.installView source
<?php
/**
* @file
* Content access install file.
*/
use Drupal\user\Entity\Role;
/**
* Implements hook_install().
*/
function content_access_install() {
$config = \Drupal::configFactory()
->getEditable('content_access.settings');
$roles_gids = [];
$roles = Role::loadMultiple();
$i = 1;
foreach ($roles as $role) {
$roles_gids[$i] = $role
->id();
$i++;
}
$config
->set('content_access_roles_gids', array_flip($roles_gids))
->save();
}
/**
* Implements hook_uninstall().
*/
function content_access_uninstall() {
content_access_disabling(TRUE);
}
/**
* Implements hook_schema().
*/
function content_access_schema() {
$schema['content_access'] = [
'fields' => [
'nid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'settings' => [
'type' => 'text',
'not null' => FALSE,
'size' => 'medium',
],
],
'primary key' => [
'nid',
],
];
return $schema;
}
Functions
Name | Description |
---|---|
content_access_install | Implements hook_install(). |
content_access_schema | Implements hook_schema(). |
content_access_uninstall | Implements hook_uninstall(). |