function opigno_learning_path_update_8012 in Opigno Learning path 8
Add "uid" field to "opigno_latest_group_activity".
Update view block "Latest active training".
File
- ./
opigno_learning_path.install, line 376 - Install, update and uninstall functions for the module.
Code
function opigno_learning_path_update_8012() {
// Add new field.
$definition = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setDescription(t('The user ID of author of the LatestActivity entity.'))
->setSetting('target_type', 'user')
->setSetting('handler', 'default');
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('uid', 'opigno_latest_group_activity', 'opigno_latest_group_activity', $definition);
// Update view block.
$config_path = drupal_get_path('module', 'opigno_learning_path') . '/config/install';
$storage = new FileStorage($config_path);
$config_storage = \Drupal::service('config.storage');
$data = $storage
->read('views.view.latest_active_trainings');
$config_storage
->write('views.view.latest_active_trainings', $data);
}