diff -u b/core/modules/media_entity/config/schema/media_entity.schema.yml b/core/modules/media_entity/config/schema/media_entity.schema.yml --- b/core/modules/media_entity/config/schema/media_entity.schema.yml +++ b/core/modules/media_entity/config/schema/media_entity.schema.yml @@ -4,7 +4,7 @@ mapping: icon_base: type: string - label: 'Base folder for icons installation' + label: 'URI where media type icons will be installed' media_entity.bundle.*: type: config_entity diff -u b/core/modules/media_entity/js/media_bundle_form.js b/core/modules/media_entity/js/media_bundle_form.js --- b/core/modules/media_entity/js/media_bundle_form.js +++ b/core/modules/media_entity/js/media_bundle_form.js @@ -28,12 +28,12 @@ } return vals.join(', '); }); - $('#edit-language', context).drupalSetSummary(function (context) { + $(context).find('#edit-language').drupalSetSummary(function (context) { var vals = []; - vals.push($('.js-form-item-language-configuration-langcode select option:selected', context).text()); + vals.push($(context).find('.js-form-item-language-configuration-langcode select option:selected').text()); - $('input:checked', context).next('label').each(function () { + $(context).find('input:checked').next('label').each(function () { vals.push(Drupal.checkPlain($(this).text())); }); diff -u b/core/modules/media_entity/media_entity.api.php b/core/modules/media_entity/media_entity.api.php --- b/core/modules/media_entity/media_entity.api.php +++ b/core/modules/media_entity/media_entity.api.php @@ -16,7 +16,7 @@ * @param array $types * The array of type plugins, keyed on the machine-readable name. */ -function hook_media_entity_type_info_alter(&$types) { +function hook_media_entity_type_info_alter(array &$types) { $types['youtube']['label'] = t('Youtube rocks!'); } diff -u b/core/modules/media_entity/media_entity.libraries.yml b/core/modules/media_entity/media_entity.libraries.yml --- b/core/modules/media_entity/media_entity.libraries.yml +++ b/core/modules/media_entity/media_entity.libraries.yml @@ -3,8 +3,6 @@ js: 'js/media_form.js': {} dependencies: - - core/jquery - - core/drupal - core/drupal.form media_bundle_form: @@ -14,4 +12,2 @@ dependencies: - - core/jquery - - core/drupal - core/drupal.form diff -u b/core/modules/media_entity/media_entity.theme.inc b/core/modules/media_entity/media_entity.theme.inc --- b/core/modules/media_entity/media_entity.theme.inc +++ b/core/modules/media_entity/media_entity.theme.inc @@ -18,7 +18,7 @@ * An associative array containing: * - media: An individual media for display. */ -function template_preprocess_media(&$variables) { +function template_preprocess_media(array &$variables) { /** @var \Drupal\media_entity\MediaInterface $media */ $media = $variables['elements']['#media']; diff -u b/core/modules/media_entity/src/Entity/Media.php b/core/modules/media_entity/src/Entity/Media.php --- b/core/modules/media_entity/src/Entity/Media.php +++ b/core/modules/media_entity/src/Entity/Media.php @@ -16,6 +16,8 @@ * @ContentEntityType( * id = "media", * label = @Translation("Media"), + * label_singular = @Translation("media item"), + * label_plural = @Translation("media items"), * bundle_label = @Translation("Media bundle"), * handlers = { * "storage" = "Drupal\Core\Entity\Sql\SqlContentEntityStorage", diff -u b/core/modules/media_entity/src/Entity/MediaBundle.php b/core/modules/media_entity/src/Entity/MediaBundle.php --- b/core/modules/media_entity/src/Entity/MediaBundle.php +++ b/core/modules/media_entity/src/Entity/MediaBundle.php @@ -60,35 +60,35 @@ * * @var string */ - public $id; + protected $id; /** * The human-readable name of the media bundle. * * @var string */ - public $label; + protected $label; /** * A brief description of this media bundle. * * @var string */ - public $description; + protected $description; /** * The type plugin id. * * @var string */ - public $type = 'generic'; + protected $type = 'generic'; /** * Are thumbnail downloads queued. * * @var bool */ - public $queue_thumbnail_downloads = FALSE; + protected $queue_thumbnail_downloads = FALSE; /** * Default value of the 'Create new revision' checkbox of this media bundle. @@ -102,7 +102,7 @@ * * @var array */ - public $type_configuration = []; + protected $type_configuration = []; /** * Type lazy plugin collection. @@ -119,13 +119,6 @@ public $field_map = []; /** - * Default status of this media bundle. - * - * @var array - */ - public $status = TRUE; - - /** * {@inheritdoc} */ public function getPluginCollections() { diff -u b/core/modules/media_entity/src/MediaBundleForm.php b/core/modules/media_entity/src/MediaBundleForm.php --- b/core/modules/media_entity/src/MediaBundleForm.php +++ b/core/modules/media_entity/src/MediaBundleForm.php @@ -12,7 +12,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Form controller for node type forms. + * Form controller for media bundle forms. */ class MediaBundleForm extends EntityForm { @@ -86,7 +86,7 @@ $form = parent::form($form, $form_state); /** @var \Drupal\media_entity\MediaBundleInterface $bundle */ - $form['#entity'] = $bundle = $this->entity; + $form['#entity'] = $bundle = $this->getEntity(); $form_state->set('bundle', $bundle->id()); if ($this->operation == 'add') { @@ -160,7 +160,7 @@ /** @var \Drupal\media_entity\MediaTypeInterface $plugin */ if ($plugin = $bundle->getType()) { - $plugin_configuration = (empty($this->configurableInstances[$plugin->getPluginId()]['plugin_config'])) ? $bundle->type_configuration : $this->configurableInstances[$plugin->getPluginId()]['plugin_config']; + $plugin_configuration = (empty($this->configurableInstances[$plugin->getPluginId()]['plugin_config'])) ? $bundle->getTypeConfiguration() : $this->configurableInstances[$plugin->getPluginId()]['plugin_config']; /** @var \Drupal\media_entity\MediaTypeBase $instance */ $instance = $this->mediaTypeManager->createInstance($plugin->getPluginId(), $plugin_configuration); // Store the configuration for validate and submit handlers. @@ -305,10 +305,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); - $workflow_options = ['status', 'queue_thumbnail_downloads']; - foreach ($workflow_options as $option) { - $this->entity->$option = (bool) $form_state->getValue(['options', $option]); - } + $this->entity->setQueueThumbnailDownloads((bool) $form_state->getValue(['options', 'queue_thumbnail_downloads'])); + $this->entity->setStatus((bool) $form_state->getValue(['options', 'status'])); $this->entity->setNewRevision((bool) $form_state->getValue(['options', 'new_revision'])); diff -u b/core/modules/media_entity/src/MediaForm.php b/core/modules/media_entity/src/MediaForm.php --- b/core/modules/media_entity/src/MediaForm.php +++ b/core/modules/media_entity/src/MediaForm.php @@ -31,7 +31,7 @@ parent::prepareEntity(); // Set up default values, if required. - if (!$this->entity->isNew()) { + if (!$this->getEntity()->isNew()) { $this->entity->setRevisionLogMessage(NULL); $this->entity->setOwnerId($this->currentUser()->id()); $this->entity->setCreatedTime(\Drupal::time()->getRequestTime()); @@ -43,7 +43,7 @@ */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); - $entity_type = $this->entity->getEntityType(); + $entity_type = $this->getEntity()->getEntityType(); /** @var \Drupal\media_entity\Entity\MediaBundle $bundle_entity */ $bundle_entity = $this->entity->bundle->entity; $account = $this->currentUser(); diff -u b/core/modules/media_entity/tests/src/Functional/MediaUiFunctionalTest.php b/core/modules/media_entity/tests/src/Functional/MediaUiFunctionalTest.php --- b/core/modules/media_entity/tests/src/Functional/MediaUiFunctionalTest.php +++ b/core/modules/media_entity/tests/src/Functional/MediaUiFunctionalTest.php @@ -82,7 +82,7 @@ // Test that there is no empty vertical tabs element, if the container is // empty (see #2750697). // Make the "Publisher ID" and "Created" fields hidden. - $this->drupalGet('/admin/structure/media/manage/' . $bundle->id . '/form-display'); + $this->drupalGet('/admin/structure/media/manage/' . $bundle->id() . '/form-display'); $page->selectFieldOption('fields[created][parent]', 'hidden'); $page->selectFieldOption('fields[uid][parent]', 'hidden'); $page->pressButton('Save'); @@ -140,10 +140,10 @@ // Checks for the first media bundle. $assert_session->pageTextContains($first_media_bundle->label()); - $assert_session->pageTextContains($first_media_bundle->description); + $assert_session->pageTextContains($first_media_bundle->getDescription()); // Checks for the second media bundle. $assert_session->pageTextContains($second_media_bundle->label()); - $assert_session->pageTextContains($second_media_bundle->description); + $assert_session->pageTextContains($second_media_bundle->getDescription()); // Continue testing media bundle filter. $first_media_item = Media::create(['bundle' => $first_media_bundle->id()]); diff -u b/core/modules/media_entity/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php b/core/modules/media_entity/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php --- b/core/modules/media_entity/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php +++ b/core/modules/media_entity/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php @@ -138,7 +138,7 @@ $this->assertTrue($loaded_bundle->shouldCreateNewRevision()); $this->assertTrue($loaded_bundle->getQueueThumbnailDownloads()); $this->assertFalse($loaded_bundle->getStatus()); - $this->assertEquals($loaded_bundle->field_map, ['field_1' => 'name']); + $this->assertEquals($loaded_bundle->getFieldMap(), ['field_1' => 'name']); // Test that a media being created with default status to "FALSE" will be // created unpublished.