summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Rowlands2017-12-12 09:41:20 (GMT)
committerLee Rowlands2017-12-12 09:41:20 (GMT)
commitb5b3949b1454d535f876e29b8d0453d31416179c (patch)
treef4c6a92cf654f1ee95d80f208b95faa1cae4e955
parentde9e2d7061c2fe2303ca926250817d4e125b91f9 (diff)
Issue #2928256 by marcoscano, seanB: Users shouldn't be able to change the media source plugin after the media type is created
-rw-r--r--core/modules/media/src/MediaTypeForm.php11
-rw-r--r--core/modules/media/tests/src/FunctionalJavascript/MediaTypeCreationTest.php4
2 files changed, 14 insertions, 1 deletions
diff --git a/core/modules/media/src/MediaTypeForm.php b/core/modules/media/src/MediaTypeForm.php
index 04ac4ba..170a34f 100644
--- a/core/modules/media/src/MediaTypeForm.php
+++ b/core/modules/media/src/MediaTypeForm.php
@@ -118,14 +118,23 @@ class MediaTypeForm extends EntityForm {
'#attributes' => ['id' => 'source-dependent'],
];
+ if ($source) {
+ $source_description = $this->t('<em>The media source cannot be changed after the media type is created.</em>');
+ }
+ else {
+ $source_description = $this->t('Media source that is responsible for additional logic related to this media type.');
+ }
$form['source_dependent']['source'] = [
'#type' => 'select',
'#title' => $this->t('Media source'),
'#default_value' => $source ? $source->getPluginId() : NULL,
'#options' => $options,
- '#description' => $this->t('Media source that is responsible for additional logic related to this media type.'),
+ '#description' => $source_description,
'#ajax' => ['callback' => '::ajaxHandlerData'],
'#required' => TRUE,
+ // Once the media type is created, its source plugin cannot be changed
+ // anymore.
+ '#disabled' => !empty($source),
];
if (!$source) {
diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaTypeCreationTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaTypeCreationTest.php
index efbe288..652aca8 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaTypeCreationTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaTypeCreationTest.php
@@ -49,6 +49,10 @@ class MediaTypeCreationTest extends MediaJavascriptTestBase {
$this->drupalGet("admin/structure/media/manage/{$mediaTypeMachineName}");
$assert_session->pageTextContains('Test source field is used to store the essential information about the media item.');
+
+ // Check that the plugin cannot be changed after it is set on type creation.
+ $assert_session->fieldDisabled('Media source');
+ $assert_session->pageTextContains('The media source cannot be changed after the media type is created.');
}
/**