You are here

function opigno_moxtra_update_8005 in Opigno Moxtra 8

Creates the training field in the meetings.

File

./opigno_moxtra.install, line 160
Install, update and uninstall functions for the Opigno Moxtra module.

Code

function opigno_moxtra_update_8005() {

  // Create a new field definition.
  $field = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Related training'))
    ->setDescription(t('The related training of the Meeting entity.'))
    ->setSettings([
    'target_type' => 'group',
    'handler' => 'default:group',
    'handler_settings' => [
      'target_bundles' => [
        'learning_path' => 'learning_path',
      ],
      'sort' => [
        'field' => '_none',
      ],
    ],
  ]);

  // Install the new definition.
  $definition_manager = \Drupal::entityDefinitionUpdateManager();
  $definition_manager
    ->installFieldStorageDefinition('training', 'opigno_moxtra_meeting', 'opigno_moxtra_meeting', $field);
}