diff --git a/core/composer.json b/core/composer.json index 7ae0ccf..e75d742 100644 --- a/core/composer.json +++ b/core/composer.json @@ -108,6 +108,7 @@ "drupal/link": "self.version", "drupal/locale": "self.version", "drupal/minimal": "self.version", + "drupal/media_entity": "self.version", "drupal/menu_link_content": "self.version", "drupal/menu_ui": "self.version", "drupal/migrate": "self.version", diff --git a/core/modules/media_entity/config/schema/media_entity.schema.yml b/core/modules/media_entity/config/schema/media_entity.schema.yml index 1c1f720..aafb50e 100644 --- a/core/modules/media_entity/config/schema/media_entity.schema.yml +++ b/core/modules/media_entity/config/schema/media_entity.schema.yml @@ -35,11 +35,6 @@ media_entity.bundle.*: label: 'Field map' sequence: type: string - third_party_settings: - type: sequence - label: 'Third party settings' - sequence: - type: media_entity.bundle.third_party.[%key] action.configuration.media_delete_action: type: action_configuration_default diff --git a/core/modules/media_entity/js/media_bundle_form.js b/core/modules/media_entity/js/media_bundle_form.js index 0f66229..145fee6 100644 --- a/core/modules/media_entity/js/media_bundle_form.js +++ b/core/modules/media_entity/js/media_bundle_form.js @@ -14,7 +14,7 @@ * @prop {Drupal~behaviorAttach} attach * Attaches summary behaviors on media bundle edit forms. */ - Drupal.behaviors.contentTypes = { + Drupal.behaviors.mediaBundles = { attach: function (context) { var $context = $(context); // Provide the vertical tab summaries. diff --git a/core/modules/media_entity/media_entity.install b/core/modules/media_entity/media_entity.install index b0c1415..1f90470 100644 --- a/core/modules/media_entity/media_entity.install +++ b/core/modules/media_entity/media_entity.install @@ -6,42 +6,6 @@ */ /** - * Checks if required version of the Entity API is installed. - * - * @return bool - * TRUE if dependency is met and FALSE if not. - */ -function _media_entity_check_entity_version() { - if (\Drupal::moduleHandler()->moduleExists('entity')) { - $info = system_get_info('module', 'entity'); - if (version_compare($info['version'], '8.x-1.0-alpha3') >= 0) { - return TRUE; - } - } - - return FALSE; -} - -/** - * Implements hook_requirements(). - */ -function media_entity_requirements($phase) { - $requirements = []; - if ($phase == 'update' && !_media_entity_check_entity_version()) { - $requirements['entity'] = [ - 'title' => t('Media entity'), - 'value' => t('Entity API missing'), - 'description' => t( - 'Entity API >= 8.x-1.0-alpha3 module is now a dependency and needs to be installed before running updates.', - [':url' => 'https://www.drupal.org/project/entity'] - ), - 'severity' => REQUIREMENT_ERROR, - ]; - } - return $requirements; -} - -/** * Implements hook_install(). */ function media_entity_install() { @@ -51,53 +15,8 @@ function media_entity_install() { } /** - * Remove "type" base field. - */ -function media_entity_update_8001() { - $fields = \Drupal::database()->query('DESCRIBE {media_field_data}')->fetchCol(); - if (in_array('type', $fields)) { - \Drupal::database()->update('media_field_data') - ->fields(['type' => NULL]) - ->execute(); - } - - $manager = \Drupal::entityDefinitionUpdateManager(); - if ($field = $manager->getFieldStorageDefinition('type', 'media')) { - $manager->uninstallFieldStorageDefinition($field); - } -} - -/** - * Ensure media entity status value (defaulting to 1). - */ -function media_entity_update_8002() { - // Ensure status values in 'media_field_data' table. - if (\Drupal::database()->schema()->tableExists('media_field_data')) { - \Drupal::database() - ->update('media_field_data') - ->fields(['status' => 1]) - ->condition('status', NULL, 'IS NULL') - ->execute(); - } - - // Ensure status values in 'media_field_revision' table. - if (\Drupal::database()->schema()->tableExists('media_field_revision')) { - \Drupal::database() - ->update('media_field_revision') - ->fields(['status' => 1]) - ->condition('status', NULL, 'IS NULL') - ->execute(); - } - - // Flush all caches. - drupal_flush_all_caches(); -} - -/** - * Ensure Entity API is installed. + * Implements hook_update_last_removed(). */ -function media_entity_update_8003() { - if (!_media_entity_check_entity_version()) { - throw new \Drupal\Core\Utility\UpdateException('Entity API >= 8.x-1.0-alpha3 (drupal.org/project/entity) module is now a dependency and needs to be installed before running updates.'); - } +function media_entity_update_last_removed() { + return 8003; } diff --git a/core/modules/media_entity/media_entity.libraries.yml b/core/modules/media_entity/media_entity.libraries.yml index be72e0a..ed0507a 100644 --- a/core/modules/media_entity/media_entity.libraries.yml +++ b/core/modules/media_entity/media_entity.libraries.yml @@ -1,3 +1,12 @@ +media_form: + version: VERSION + js: + 'js/media_form.js': {} + dependencies: + - core/jquery + - core/drupal + - core/drupal.form + media_bundle_form: version: VERSION js: diff --git a/core/modules/media_entity/media_entity.module b/core/modules/media_entity/media_entity.module index d54f773..5f75514 100644 --- a/core/modules/media_entity/media_entity.module +++ b/core/modules/media_entity/media_entity.module @@ -68,6 +68,7 @@ function media_entity_theme_suggestions_media(array $variables) { * Destination folder. * * @throws Exception + * Thrown when media icons can't be copied to their destination. */ function media_entity_copy_icons($source, $destination) { if (!file_prepare_directory($destination, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) { diff --git a/core/modules/media_entity/media_entity.permissions.yml b/core/modules/media_entity/media_entity.permissions.yml index 6a55f92..1a748d9 100644 --- a/core/modules/media_entity/media_entity.permissions.yml +++ b/core/modules/media_entity/media_entity.permissions.yml @@ -10,11 +10,11 @@ access media overview: view media: title: 'View media' update media: - title: 'Update media' + title: 'Update own media' update any media: title: 'Update any media' delete media: - title: 'Delete media' + title: 'Delete own media' delete any media: title: 'Delete any media' create media: diff --git a/core/modules/media_entity/media_entity.theme.inc b/core/modules/media_entity/media_entity.theme.inc index 605348c..9ccc6f5 100644 --- a/core/modules/media_entity/media_entity.theme.inc +++ b/core/modules/media_entity/media_entity.theme.inc @@ -10,31 +10,6 @@ use Drupal\Component\Utility\Html; /** - * Prepares variables for list of available media bundles. - * - * Default template: media-add-list.html.twig. - * - * @param array $variables - * An associative array containing: - * - content: An array of content types. - */ -function template_preprocess_media_add_list(&$variables) { - $variables['bundles'] = []; - if (!empty($variables['content'])) { - foreach ($variables['content'] as $bundle) { - /** @var \Drupal\media_entity\MediaBundleInterface $bundle */ - $variables['bundles'][$bundle->id()] = [ - 'type' => $bundle->id(), - 'add_link' => Link::createFromRoute($bundle->label(), 'media.add', ['media_bundle' => $bundle->id()]), - 'description' => [ - '#markup' => $bundle->getDescription(), - ], - ]; - } - } -} - -/** * Prepares variables for media templates. * * Default template: media.html.twig. diff --git a/core/modules/media_entity/media_entity.tokens.inc b/core/modules/media_entity/media_entity.tokens.inc index 58bd861..31f72be 100644 --- a/core/modules/media_entity/media_entity.tokens.inc +++ b/core/modules/media_entity/media_entity.tokens.inc @@ -49,10 +49,6 @@ function media_entity_token_info() { 'name' => t('Name'), 'description' => t('The name of this media.'), ]; - $media['type'] = [ - 'name' => t("Type"), - 'description' => t("The type of this media."), - ]; $node['author'] = [ 'name' => t("Author"), 'type' => 'user', @@ -97,10 +93,8 @@ function media_entity_tokens($type, $tokens, array $data, array $options, Bubble else { $langcode = LanguageInterface::LANGCODE_DEFAULT; } - $sanitize = !empty($options['sanitize']); $replacements = []; - if ($type == 'media' && !empty($data['media'])) { /** @var \Drupal\media_entity\MediaInterface $media */ $media = \Drupal::service('entity.repository')->getTranslationFromContext($data['media'], $langcode, ['operation' => 'media_entity_tokens']); @@ -121,26 +115,19 @@ function media_entity_tokens($type, $tokens, array $data, array $options, Bubble break; case 'bundle': - $replacements[$original] = $sanitize ? Html::escape($media->bundle()) : $media->bundle(); + $replacements[$original] = $media->bundle(); break; case 'bundle-name': - $bundle_name = MediaBundle::load($media->bundle())->label(); - $replacements[$original] = $sanitize ? Html::escape($bundle_name) : $bundle_name; + $replacements[$original] = $media->bundle->entity->label(); break; case 'langcode': - $replacements[$original] = $sanitize ? Html::escape($media->language()->getId()) : $media->language()->getId(); + $replacements[$original] = $media->language()->getId(); break; case 'name': - $media_name = $media->get('name')->value; - $replacements[$original] = $sanitize ? Html::escape($media_name) : $media_name; - break; - - case 'type': - $media_type = $media->get('name')->value; - $replacements[$original] = $sanitize ? Html::escape($media_type) : $media_type; + $replacements[$original] = $media->name->value; break; case 'url': @@ -154,9 +141,9 @@ function media_entity_tokens($type, $tokens, array $data, array $options, Bubble // Default values for the chained tokens handled below. case 'author': /** @var \Drupal\user\UserInterface $account */ - $account = $media->get('uid')->entity; + $account = $media->getPublisher(); $bubbleable_metadata->addCacheableDependency($account); - $replacements[$original] = $sanitize ? Html::escape($account->label()) : $account->label(); + $replacements[$original] = $account->label(); break; case 'created': diff --git a/core/modules/media_entity/src/Entity/Media.php b/core/modules/media_entity/src/Entity/Media.php index 95d2151..2543318 100644 --- a/core/modules/media_entity/src/Entity/Media.php +++ b/core/modules/media_entity/src/Entity/Media.php @@ -18,7 +18,7 @@ * label = @Translation("Media"), * bundle_label = @Translation("Media bundle"), * handlers = { - * "storage" = "Drupal\media_entity\MediaStorage", + * "storage" = "Drupal\Core\Entity\Sql\SqlContentEntityStorage", * "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", * "list_builder" = "Drupal\Core\Entity\EntityListBuilder", * "access" = "Drupal\media_entity\MediaAccessController", @@ -76,13 +76,6 @@ class Media extends ContentEntityBase implements MediaInterface { const NOT_PUBLISHED = 0; /** - * A queue based media operation to download thumbnails is being performed. - * - * @var boolean - */ - protected $queued_thumbnail_download = FALSE; - - /** * {@inheritdoc} */ public function getCreatedTime() { @@ -100,37 +93,53 @@ public function setCreatedTime($timestamp) { /** * {@inheritdoc} */ - public function getChangedTime() { - return $this->get('changed')->value; + public function isPublished() { + return (bool) $this->get('status')->value; } /** * {@inheritdoc} */ - public function isPublished() { - return (bool) $this->get('status')->value; + public function setPublished($published) { + $this->set('status', $published ? Media::PUBLISHED : Media::NOT_PUBLISHED); + return $this; } /** * {@inheritdoc} */ - public function setPublished($published) { - $this->set('status', $published ? Media::PUBLISHED : Media::NOT_PUBLISHED); + public function getOwner() { + $this->get('uid')->entity; + } + + /** + * {@inheritdoc} + */ + public function setOwner(UserInterface $account) { + $this->set('uid', $account->id()); return $this; } /** * {@inheritdoc} */ - public function getPublisher() { - return $this->get('uid')->entity; + public function getOwnerId() { + $this->get('uid')->target_id; } /** * {@inheritdoc} */ - public function setQueuedThumbnailDownload() { - $this->queued_thumbnail_download = TRUE; + public function setOwnerId($uid) { + $this->set('uid', $uid); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getPublisher() { + return $this->get('uid')->entity; } /** @@ -164,21 +173,19 @@ public function preSave(EntityStorageInterface $storage) { // If no revision author has been set explicitly, make the media owner the // revision author. if (!$this->get('revision_uid')->entity) { - $this->set('revision_uid', $this->getPublisherId()); + $this->setRevisionUserId($this->getOwnerId()); } // Set thumbnail. - if (!$this->get('thumbnail')->entity || !empty($this->queued_thumbnail_download)) { + if (!$this->get('thumbnail')->entity) { $this->automaticallySetThumbnail(); } // Try to set fields provided by type plugin and mapped in bundle // configuration. - foreach ($this->bundle->entity->field_map as $source_field => $destination_field) { + foreach ($this->bundle->entity->getFieldMap() as $source_field => $destination_field) { // Only save value in entity field if empty. Do not overwrite existing // data. - // @TODO We might modify that in the future but let's leave it like this - // for now. if ($this->hasField($destination_field) && $this->{$destination_field}->isEmpty() && ($value = $this->getType()->getField($this, $source_field))) { $this->set($destination_field, $value); } @@ -223,7 +230,7 @@ public function automaticallySetThumbnail() { else { /** @var \Drupal\file\FileInterface $file */ $file = $this->entityTypeManager()->getStorage('file')->create(['uri' => $thumbnail_uri]); - if ($publisher = $this->getPublisher()) { + if ($publisher = $this->getOwner()) { $file->setOwner($publisher); } $file->setPermanent(); @@ -263,41 +270,7 @@ public function validate() { * {@inheritdoc} */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { - $fields['mid'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Media ID')) - ->setDescription(t('The media ID.')) - ->setReadOnly(TRUE) - ->setSetting('unsigned', TRUE); - - $fields['uuid'] = BaseFieldDefinition::create('uuid') - ->setLabel(t('UUID')) - ->setDescription(t('The media UUID.')) - ->setReadOnly(TRUE); - - $fields['vid'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Revision ID')) - ->setDescription(t('The media revision ID.')) - ->setReadOnly(TRUE) - ->setSetting('unsigned', TRUE); - - $fields['bundle'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Bundle')) - ->setDescription(t('The media bundle.')) - ->setSetting('target_type', 'media_bundle') - ->setReadOnly(TRUE); - - $fields['langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Language code')) - ->setDescription(t('The media language code.')) - ->setTranslatable(TRUE) - ->setRevisionable(TRUE) - ->setDisplayOptions('view', [ - 'type' => 'hidden', - ]) - ->setDisplayOptions('form', [ - 'type' => 'language_select', - 'weight' => 2, - ]); + $fields = parent::baseFieldDefinitions($entity_type); $fields['name'] = BaseFieldDefinition::create('string') ->setLabel(t('Media name')) @@ -457,14 +430,14 @@ public function setRevisionUser(UserInterface $account) { * {@inheritdoc} */ public function getRevisionUserId() { - return $this->revision_user->target_id; + return $this->revision_uid->target_id; } /** * {@inheritdoc} */ public function setRevisionUserId($user_id) { - $this->revision_user->target_id = $user_id; + $this->revision_uid->target_id = $user_id; return $this; } @@ -479,7 +452,7 @@ public function getRevisionLogMessage() { * {@inheritdoc} */ public function setRevisionLogMessage($revision_log_message) { - $this->revision_log->value = $revision_log_message; + $this->revision_log-> value = $revision_log_message; return $this; } diff --git a/core/modules/media_entity/src/Entity/MediaBundle.php b/core/modules/media_entity/src/Entity/MediaBundle.php index 7461c8a..c98a098 100644 --- a/core/modules/media_entity/src/Entity/MediaBundle.php +++ b/core/modules/media_entity/src/Entity/MediaBundle.php @@ -128,13 +128,6 @@ class MediaBundle extends ConfigEntityBundleBase implements MediaBundleInterface /** * {@inheritdoc} */ - public function id() { - return $this->id; - } - - /** - * {@inheritdoc} - */ public function getPluginCollections() { return [ 'type_configuration' => $this->typePluginCollection(), @@ -230,7 +223,7 @@ public function getStatus() { /** * {@inheritdoc} */ - public function isNewRevision() { + public function shouldCreateNewRevision() { return $this->new_revision; } @@ -241,4 +234,11 @@ public function setNewRevision($new_revision) { $this->new_revision = $new_revision; } + /** + * {@inheritdoc} + */ + public function getFieldMap() { + return $this->field_map; + } + } diff --git a/core/modules/media_entity/src/MediaBundleForm.php b/core/modules/media_entity/src/MediaBundleForm.php index addf384..66f0cca 100644 --- a/core/modules/media_entity/src/MediaBundleForm.php +++ b/core/modules/media_entity/src/MediaBundleForm.php @@ -216,12 +216,13 @@ public function form(array $form, FormStateInterface $form_state) { } } + $field_map = $bundle->getFieldMap(); foreach ($plugin->providedFields() as $field_name => $field_label) { $form['field_mapping'][$field_name] = [ '#type' => 'select', '#title' => $field_label, '#options' => $options, - '#default_value' => isset($bundle->field_map[$field_name]) ? $bundle->field_map[$field_name] : '_none', + '#default_value' => isset($field_map[$field_name]) ? $field_map[$field_name] : '_none', ]; } } @@ -242,7 +243,7 @@ public function form(array $form, FormStateInterface $form_state) { $workflow_options = [ 'status' => $bundle->getStatus(), - 'new_revision' => $bundle->isNewRevision(), + 'new_revision' => $bundle->shouldCreateNewRevision(), 'queue_thumbnail_downloads' => $bundle->getQueueThumbnailDownloads(), ]; // Prepare workflow options to be used for 'checkboxes' form element. diff --git a/core/modules/media_entity/src/MediaBundleInterface.php b/core/modules/media_entity/src/MediaBundleInterface.php index 371cbad..6a2332c 100644 --- a/core/modules/media_entity/src/MediaBundleInterface.php +++ b/core/modules/media_entity/src/MediaBundleInterface.php @@ -93,7 +93,7 @@ public function getStatus(); * @return bool * TRUE if a new revision should be created by default. */ - public function isNewRevision(); + public function shouldCreateNewRevision(); /** * Sets whether a new revision should be created by default. @@ -103,4 +103,13 @@ public function isNewRevision(); */ public function setNewRevision($new_revision); + /** + * Returns the metadata field map. + * + * @return array + * Field mapping array with fields provided by the type plugin as keys and + * Drupal Entity fields as values. + */ + public function getFieldMap(); + } diff --git a/core/modules/media_entity/src/MediaForm.php b/core/modules/media_entity/src/MediaForm.php index 0bd16b5..b728fad 100644 --- a/core/modules/media_entity/src/MediaForm.php +++ b/core/modules/media_entity/src/MediaForm.php @@ -47,7 +47,7 @@ public function form(array $form, FormStateInterface $form_state) { /** @var \Drupal\media_entity\Entity\MediaBundle $bundle_entity */ $bundle_entity = $this->entity->bundle->entity; $account = $this->currentUser(); - $new_revision = $this->entity->bundle->entity->isNewRevision(); + $new_revision = $this->entity->bundle->entity->shouldCreateNewRevision(); if ($this->operation == 'edit') { $form['#title'] = $this->t('Edit %bundle_label @label', [ @@ -71,6 +71,9 @@ public function form(array $form, FormStateInterface $form_state) { '#group' => 'advanced', '#weight' => 20, '#access' => $new_revision || $account->hasPermission($entity_type->get('admin_permission')), + '#attributes' => [ + 'class' => ['media-form-revision-information'], + ], ]; $form['revision_information']['revision'] = [ @@ -106,10 +109,7 @@ public function form(array $form, FormStateInterface $form_state) { '#title' => $this->t('Authoring information'), '#group' => 'advanced', '#attributes' => [ - 'class' => ['node-form-author'], - ], - '#attached' => [ - 'library' => ['node/drupal.node'], + 'class' => ['media-form-author'], ], '#weight' => 90, '#optional' => TRUE, @@ -124,7 +124,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['created']['#group'] = 'author'; } - $form['#attached']['library'][] = 'node/form'; + $form['#attached']['library'][] = 'media_entity/media_form'; $form['#entity_builders']['update_status'] = [$this, 'updateStatus']; @@ -230,17 +230,9 @@ public function save(array $form, FormStateInterface $form_state) { drupal_set_message($this->t('@type %info has been updated.', $t_args)); } - if ($this->entity->id()) { - $form_state->setValue('id', $this->entity->id()); - $form_state->set('id', $this->entity->id()); - $form_state->setRedirectUrl($this->entity->toUrl('canonical')); - } - else { - // In the unlikely case something went wrong on save, the entity will be - // rebuilt and entity form redisplayed. - drupal_set_message($this->t('The entity could not be saved.'), 'error'); - $form_state->setRebuild(); - } + $form_state->setValue('id', $this->entity->id()); + $form_state->set('id', $this->entity->id()); + $form_state->setRedirectUrl($this->entity->toUrl('canonical')); } } diff --git a/core/modules/media_entity/src/MediaInterface.php b/core/modules/media_entity/src/MediaInterface.php index 63f7d0b..23513fc 100644 --- a/core/modules/media_entity/src/MediaInterface.php +++ b/core/modules/media_entity/src/MediaInterface.php @@ -5,11 +5,12 @@ use Drupal\Core\Entity\EntityChangedInterface; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\RevisionLogInterface; +use Drupal\user\EntityOwnerInterface; /** * Provides an interface defining a media entity. */ -interface MediaInterface extends ContentEntityInterface, EntityChangedInterface, RevisionLogInterface { +interface MediaInterface extends ContentEntityInterface, EntityChangedInterface, RevisionLogInterface, EntityOwnerInterface { /** * Returns the media creation timestamp. @@ -31,15 +32,13 @@ public function getCreatedTime(); public function setCreatedTime($timestamp); /** - * Sets a flag to indicate the thumbnail will be retrieved via a queue. - */ - public function setQueuedThumbnailDownload(); - - /** * Returns the media publisher user entity. * * @return \Drupal\user\UserInterface * The author user entity. + * + * @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0. Use + * \Drupal\user\EntityOwnerInterface::getOwner() instead. */ public function getPublisher(); @@ -48,6 +47,9 @@ public function getPublisher(); * * @return int * The author user ID. + * + * @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0. Use + * \Drupal\user\EntityOwnerInterface::getOwnerId() instead. */ public function getPublisherId(); @@ -59,6 +61,9 @@ public function getPublisherId(); * * @return \Drupal\media_entity\MediaInterface * The called media entity. + * + * @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0. Use + * \Drupal\user\EntityOwnerInterface::setOwnerId() instead. */ public function setPublisherId($uid); @@ -92,8 +97,10 @@ public function setPublished($published); public function getType(); /** - * Automatically determines the most appropriate thumbnail and sets - * "thumbnail" field. + * Automatically determines the most appropriate thumbnail. + * + * Determines (with help of type plugin) the thumbnail image and sets the + * value of the thumbnail base field. */ public function automaticallySetThumbnail(); diff --git a/core/modules/media_entity/src/MediaStorage.php b/core/modules/media_entity/src/MediaStorage.php deleted file mode 100644 index ca7efbe..0000000 --- a/core/modules/media_entity/src/MediaStorage.php +++ /dev/null @@ -1,12 +0,0 @@ -entityTypeManager = $entity_type_manager; $this->entityFieldManager = $entity_field_manager; - $this->config = $config; + $this->configFactory = $config_factory; $this->setConfiguration($configuration); } @@ -80,7 +79,7 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_definition, $container->get('entity_type.manager'), $container->get('entity_field.manager'), - $container->get('config.factory')->get('media_entity.settings') + $container->get('config.factory') ); } diff --git a/core/modules/media_entity/src/MediaViewsData.php b/core/modules/media_entity/src/MediaViewsData.php index c13b8b2..f1a4e6f 100644 --- a/core/modules/media_entity/src/MediaViewsData.php +++ b/core/modules/media_entity/src/MediaViewsData.php @@ -17,13 +17,6 @@ public function getViewsData() { $data['media_field_data']['table']['wizard_id'] = 'media'; $data['media_field_revision']['table']['wizard_id'] = 'media_revision'; - $data['media']['media_bulk_form'] = [ - 'title' => $this->t('Media operations bulk form'), - 'help' => $this->t('Add a form element that lets you run operations on multiple media entities.'), - 'field' => [ - 'id' => 'media_bulk_form', - ], - ]; return $data; } diff --git a/core/modules/media_entity/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php b/core/modules/media_entity/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php index ca4fb6b..a94d121 100644 --- a/core/modules/media_entity/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php +++ b/core/modules/media_entity/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php @@ -168,8 +168,9 @@ public function viewElements(FieldItemListInterface $items, $langcode) { } // Collect cache tags related to the image style setting. - $image_style = $this->imageStyleStorage->load($image_style_setting); - $this->renderer->addCacheableDependency($elements, $image_style); + if ($image_link_setting && ($image_style = $this->imageStyleStorage->load($image_style_setting))) { + $this->renderer->addCacheableDependency($elements, $image_style); + } return $elements; } diff --git a/core/modules/media_entity/src/Plugin/MediaEntity/Type/Generic.php b/core/modules/media_entity/src/Plugin/MediaEntity/Type/Generic.php index b83ba9d..3a3b40c 100644 --- a/core/modules/media_entity/src/Plugin/MediaEntity/Type/Generic.php +++ b/core/modules/media_entity/src/Plugin/MediaEntity/Type/Generic.php @@ -35,7 +35,7 @@ public function getField(MediaInterface $media, $name) { * {@inheritdoc} */ public function thumbnail(MediaInterface $media) { - return $this->config->get('icon_base') . '/generic.png'; + return $this->configFactory->get('media_entity.settings')->get('icon_base') . '/generic.png'; } /** diff --git a/core/modules/media_entity/src/Plugin/QueueWorker/thumbnailDownloader.php b/core/modules/media_entity/src/Plugin/QueueWorker/thumbnailDownloader.php index 8dc5538..165f6ab 100644 --- a/core/modules/media_entity/src/Plugin/QueueWorker/thumbnailDownloader.php +++ b/core/modules/media_entity/src/Plugin/QueueWorker/thumbnailDownloader.php @@ -20,10 +20,9 @@ class ThumbnailDownloader extends QueueWorkerBase { * {@inheritdoc} */ public function processItem($data) { + /** @var \Drupal\media_entity\MediaInterface $entity */ if ($entity = Media::load($data['id'])) { - // Indicate that the entity is being processed from a queue and that - // thumbnail images should be downloaded. - $entity->setQueuedThumbnailDownload(); + $entity->automaticallySetThumbnail(); $entity->save(); } } diff --git a/core/modules/media_entity/src/Plugin/views/field/MediaBulkForm.php b/core/modules/media_entity/src/Plugin/views/field/MediaBulkForm.php deleted file mode 100644 index 3cb19a5..0000000 --- a/core/modules/media_entity/src/Plugin/views/field/MediaBulkForm.php +++ /dev/null @@ -1,21 +0,0 @@ -t('No media selected.'); - } - -} diff --git a/core/modules/media_entity/src/Plugin/views/wizard/Media.php b/core/modules/media_entity/src/Plugin/views/wizard/Media.php index 1abf6ca..3a2d9da 100644 --- a/core/modules/media_entity/src/Plugin/views/wizard/Media.php +++ b/core/modules/media_entity/src/Plugin/views/wizard/Media.php @@ -51,7 +51,7 @@ protected function defaultDisplayOptions() { // Add permission-based access control. $display_options['access']['type'] = 'perm'; - $display_options['access']['options']['perm'] = 'access content'; + $display_options['access']['options']['perm'] = 'view media'; // Remove the default fields, since we are customizing them here. unset($display_options['fields']); diff --git a/core/modules/media_entity/src/Tests/MediaUITest.php b/core/modules/media_entity/src/Tests/MediaUITest.php index 4167607..c2a7c31 100644 --- a/core/modules/media_entity/src/Tests/MediaUITest.php +++ b/core/modules/media_entity/src/Tests/MediaUITest.php @@ -41,7 +41,6 @@ class MediaUITest extends WebTestBase { 'views_ui', 'node', 'block', - 'entity', ]; /** @@ -185,7 +184,7 @@ public function testMediaBundles() { $this->assertEqual($loaded_bundle->getDescription(), $bundle['description'], 'Media bundle description saved correctly.'); $this->assertEqual($loaded_bundle->getType()->getPluginId(), $bundle['type'], 'Media bundle type saved correctly.'); $this->assertEqual($loaded_bundle->getType()->getConfiguration()['test_config_value'], $bundle['type_configuration[test_type][test_config_value]'], 'Media bundle type configuration saved correctly.'); - $this->assertTrue($loaded_bundle->isNewRevision(), 'New revisions are configured to be created.'); + $this->assertTrue($loaded_bundle->shouldCreateNewRevision(), 'New revisions are configured to be created.'); $this->assertTrue($loaded_bundle->getQueueThumbnailDownloads(), 'Thumbnails are created through queues.'); $this->assertFalse($loaded_bundle->getStatus(), 'Default status is unpublished.'); $this->assertEqual($loaded_bundle->field_map, ['field_1' => $bundle['field_mapping[field_1]']], 'Field mapping was saved correctly.');