You are here

function opigno_moxtra_update_8011 in Opigno Moxtra 8

Creates the training field in the meetings.

File

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

Code

function opigno_moxtra_update_8011() {

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

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