social_event_type.install in Open Social 8.5
Same filename and directory in other branches
- 8.9 modules/social_features/social_event/modules/social_event_type/social_event_type.install
- 8 modules/social_features/social_event/modules/social_event_type/social_event_type.install
- 8.2 modules/social_features/social_event/modules/social_event_type/social_event_type.install
- 8.3 modules/social_features/social_event/modules/social_event_type/social_event_type.install
- 8.4 modules/social_features/social_event/modules/social_event_type/social_event_type.install
- 8.6 modules/social_features/social_event/modules/social_event_type/social_event_type.install
- 8.7 modules/social_features/social_event/modules/social_event_type/social_event_type.install
- 8.8 modules/social_features/social_event/modules/social_event_type/social_event_type.install
- 10.3.x modules/social_features/social_event/modules/social_event_type/social_event_type.install
- 10.0.x modules/social_features/social_event/modules/social_event_type/social_event_type.install
- 10.1.x modules/social_features/social_event/modules/social_event_type/social_event_type.install
- 10.2.x modules/social_features/social_event/modules/social_event_type/social_event_type.install
Install, update and uninstall functions for the social_event_type module.
File
modules/social_features/social_event/modules/social_event_type/social_event_type.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the social_event_type module.
*/
use Drupal\user\Entity\Role;
/**
* Implements hook_install().
*
* Perform actions related to the installation of social_event_type.
*/
function social_event_type_install() {
// Fetch sitemananger role.
$role = Role::load('sitemanager');
// Set permission for site manager.
if ($role instanceof Role) {
// Set permission.
$role
->grantPermission('set social event type settings');
$role
->grantPermission('edit terms in event_types');
$role
->grantPermission('delete terms in event_types');
$role
->trustData()
->save();
// Set default event type settings.
$config = \Drupal::configFactory()
->getEditable('social_event_type.settings');
$config
->set('social_event_type_required', FALSE);
$config
->set('social_event_type_select_changer', 5);
$config
->save();
}
}
/**
* Implements hook_uninstall().
*
* Perform actions related to the de-installation of social_event_type.
*/
function social_event_type_uninstall() {
// Fetch sitemananger role.
$role = Role::load('sitemanager');
// Set permission for site manager.
if ($role instanceof Role) {
// Set permission.
$role
->revokePermission('set social event type settings');
$role
->revokePermission('edit terms in event_types');
$role
->revokePermission('delete terms in event_types');
$role
->trustData()
->save();
}
// Also remove the fields and the vocabulary.
\Drupal::configFactory()
->getEditable('field.field.node.event.field_event_type')
->delete();
\Drupal::configFactory()
->getEditable('field.storage.node.field_event_type')
->delete();
\Drupal::configFactory()
->getEditable('taxonomy.vocabulary.event_types')
->delete();
\Drupal::configFactory()
->getEditable('social_event_type.settings')
->delete();
}
Functions
Name | Description |
---|---|
social_event_type_install | Implements hook_install(). |
social_event_type_uninstall | Implements hook_uninstall(). |