media_entity_brightcove.module in Brightcove Video Connect 3.x
Same filename and directory in other branches
The module file for media_entity_brightcove.
File
modules/media_entity_brightcove/media_entity_brightcove.moduleView source
<?php
/**
* @file
* The module file for media_entity_brightcove.
*/
use Drupal\media_entity\Entity\MediaBundle;
@trigger_error('The Media Entity Brightcove submodule is deprecated in brightcove:8.x-2.1 and will be removed from brightcove:8.x-3.0. See the issue for more details: https://www.drupal.org/node/2820436.', E_USER_DEPRECATED);
/**
* Implements hook_ENTITY_TYPE_insert() for media_bundle.
*/
function media_entity_brightcove_media_bundle_insert(MediaBundle $bundle) {
$field_name = $bundle->type_configuration['source_field'];
$form_display_settings = [
'type' => 'brightcove_inline_entity_form_complex',
'settings' => [
'form_mode' => 'default',
'allow_new' => 1,
'allow_existing' => 1,
'match_operator' => 'CONTAINS',
],
'third_party_settings' => [],
'weight' => 0,
];
// Create (or update) the entity form display for this new media bundle to
// include this new field with some more sane defaults.
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $entity_form_display_storage */
$entity_form_display_storage = \Drupal::getContainer()
->get('entity_type.manager')
->getStorage('entity_form_display');
/** @var \Drupal\Core\Entity\Entity\EntityFormDisplay $entity_form_display */
$entity_form_display = $entity_form_display_storage
->load('media.' . $bundle
->id() . '.default');
if (!$entity_form_display) {
$values = [
'status' => TRUE,
'targetEntityType' => 'media',
'bundle' => $bundle
->id(),
'mode' => 'default',
'content' => [
$field_name => $form_display_settings,
],
];
$entity_form_display = $entity_form_display_storage
->create($values);
}
else {
$entity_form_display
->setComponent($field_name, $form_display_settings);
}
$entity_form_display_storage
->save($entity_form_display);
}
Functions
Name | Description |
---|---|
media_entity_brightcove_media_bundle_insert | Implements hook_ENTITY_TYPE_insert() for media_bundle. |