You are here

function media_expire_media_bundle_form_builder in Media Expire 8

Entity builder for Media bundle.

Adds third party settings to Media bundle config entity.

See also

media_expire_form_media_bundle_form_alter()

1 string reference to 'media_expire_media_bundle_form_builder'
media_expire_form_media_bundle_form_alter in ./media_expire.module
Implements hook_form_BASE_ID_alter().

File

./media_expire.module, line 98
The Media Expires Drupal module.

Code

function media_expire_media_bundle_form_builder($entity_type, MediaBundleInterface $bundle, &$form, FormStateInterface $form_state) {
  $bundle
    ->setThirdPartySetting('media_expire', 'enable_expiring', $form_state
    ->getValue('enable_expiring'));
  $bundle
    ->setThirdPartySetting('media_expire', 'expire_field', $form_state
    ->getValue('expire_field'));
  if ($match = $form_state
    ->getValue('fallback_media')) {
    $mediaStorage = \Drupal::entityTypeManager()
      ->getStorage('media');
    if ($media = $mediaStorage
      ->load($match)) {
      $bundle
        ->setThirdPartySetting('media_expire', 'fallback_media', $media
        ->uuid());
    }
  }
}