diff --git a/src/Entity/MediaBundle.php b/src/Entity/MediaBundle.php index e7d3295..18151c6 100644 --- a/src/Entity/MediaBundle.php +++ b/src/Entity/MediaBundle.php @@ -256,9 +256,9 @@ class MediaBundle extends ConfigEntityBundleBase implements MediaBundleInterface // When creating new bundles, add also a source field, if configured to // do so. $media_type_manager = \Drupal::service('plugin.manager.media_entity.type'); + $configuration = $this->getTypeConfiguration(); /** @var \Drupal\media_entity\MediaTypeInterface $instance */ - $instance = $media_type_manager->createInstance($this->getType()->getPluginId(), $this->getTypeConfiguration()); - $configuration = $instance->getConfiguration(); + $instance = $media_type_manager->createInstance($this->getType()->getPluginId(), $configuration); $source_field_info = $instance->getDefaultSourceField(); diff --git a/tests/modules/media_entity_test_type/src/Plugin/MediaEntity/Type/TestType.php b/tests/modules/media_entity_test_type/src/Plugin/MediaEntity/Type/TestType.php index a2c5049..39e30d0 100644 --- a/tests/modules/media_entity_test_type/src/Plugin/MediaEntity/Type/TestType.php +++ b/tests/modules/media_entity_test_type/src/Plugin/MediaEntity/Type/TestType.php @@ -106,11 +106,13 @@ class TestType extends Generic { ]); } return [ - 'storage' => $storage, - 'field_name' => static::MEDIA_ENTITY_TEST_TYPE_DEFAULT_FIELD_NAME, - 'label' => $this->t('Test source field'), - 'field_widget' => static::MEDIA_ENTITY_TEST_TYPE_DEFAULT_FIELD_WIDGET, - 'field_formatter' => static::MEDIA_ENTITY_TEST_TYPE_DEFAULT_FIELD_FORMATTER, + 'source_field' => [ + 'storage' => $storage, + 'field_name' => static::MEDIA_ENTITY_TEST_TYPE_DEFAULT_FIELD_NAME, + 'label' => $this->t('Test source field'), + 'widget' => static::MEDIA_ENTITY_TEST_TYPE_DEFAULT_FIELD_WIDGET, + 'formatter' => static::MEDIA_ENTITY_TEST_TYPE_DEFAULT_FIELD_FORMATTER, + ], ]; } diff --git a/tests/src/FunctionalJavascript/BundleCreationTest.php b/tests/src/FunctionalJavascript/BundleCreationTest.php index 7483065..2a47df5 100644 --- a/tests/src/FunctionalJavascript/BundleCreationTest.php +++ b/tests/src/FunctionalJavascript/BundleCreationTest.php @@ -42,10 +42,12 @@ class BundleCreationTest extends MediaEntityJavascriptTestBase { $this->assertSession()->optionExists('type', 'test_type'); $page->selectFieldOption('type', 'test_type'); $this->waitForAjaxToFinish(); +$this->saveHtmlOutput(); // Make sure the checkbox for creating the source field is there and save. $this->assertSession()->checkboxChecked('type_configuration[test_type][create_source_field]'); $page->pressButton('Save media bundle'); +$this->saveHtmlOutput(); // Check whether the source field was correctly created. // @TODO Finish me.