diff --git a/core/modules/media/src/Entity/Media.php b/core/modules/media/src/Entity/Media.php index c63a6ffcc1..2fed9b1daf 100644 --- a/core/modules/media/src/Entity/Media.php +++ b/core/modules/media/src/Entity/Media.php @@ -88,20 +88,6 @@ class Media extends EditorialContentEntityBase implements MediaInterface { /** * {@inheritdoc} */ - public function getType() { - return $this->bundle(); - } - - /** - * {@inheritdoc} - */ - public function label() { - return $this->getName(); - } - - /** - * {@inheritdoc} - */ public function getName() { $name = $this->get('name'); diff --git a/core/modules/media/src/MediaInterface.php b/core/modules/media/src/MediaInterface.php index d2d038fe3c..912bf97f3e 100644 --- a/core/modules/media/src/MediaInterface.php +++ b/core/modules/media/src/MediaInterface.php @@ -14,14 +14,6 @@ interface MediaInterface extends ContentEntityInterface, EntityChangedInterface, RevisionLogInterface, EntityOwnerInterface, EntityPublishedInterface { /** - * Gets the media type. - * - * @return string - * The media type. - */ - public function getType(); - - /** * Gets the media item name. * * @return string @@ -35,8 +27,7 @@ public function getName(); * @param string $name * The name of the media item. * - * @return \Drupal\media\MediaInterface - * The called media entity. + * @return $this */ public function setName($name); diff --git a/core/modules/media/tests/src/Kernel/MediaCreationTest.php b/core/modules/media/tests/src/Kernel/MediaCreationTest.php index be8f4f7647..baf837f2c2 100644 --- a/core/modules/media/tests/src/Kernel/MediaCreationTest.php +++ b/core/modules/media/tests/src/Kernel/MediaCreationTest.php @@ -49,7 +49,7 @@ public function testMediaEntityCreation() { $this->assertNotInstanceOf(MediaInterface::class, Media::load(rand(1000, 9999)), 'Failed asserting a non-existent media.'); $this->assertInstanceOf(MediaInterface::class, Media::load($media->id()), 'The new media item has not been created in the database.'); - $this->assertEquals($this->testMediaType->id(), $media->getType(), 'The media item was not created with the correct type.'); + $this->assertEquals($this->testMediaType->id(), $media->bundle(), 'The media item was not created with the correct type.'); $this->assertEquals('Unnamed', $media->getName(), 'The media item was not created with the correct name.'); $source_field_name = $media->bundle->entity->getSource()->getSourceFieldDefinition($media->bundle->entity)->getName(); $this->assertEquals('Nation of sheep, ruled by wolves, owned by pigs.', $media->get($source_field_name)->value, 'Source returns incorrect source field value.'); diff --git a/core/modules/media/tests/src/Kernel/MediaSourceTest.php b/core/modules/media/tests/src/Kernel/MediaSourceTest.php index 5b6f20a39d..fc30326fb1 100644 --- a/core/modules/media/tests/src/Kernel/MediaSourceTest.php +++ b/core/modules/media/tests/src/Kernel/MediaSourceTest.php @@ -24,11 +24,11 @@ public function testDefaultName() { $media = Media::create(['bundle' => $this->testMediaType->id()]); $media_source = $media->getSource(); $this->assertEquals('default_name', $media_source->getPluginDefinition()['default_name_metadata_attribute'], 'Default metadata attribute is not used for the default name.'); - $this->assertEquals('media:' . $media->getType() . ':' . $media->uuid(), $media_source->getMetadata($media, 'default_name'), 'Value of the default name metadata attribute does not look correct.'); - $this->assertEquals('media:' . $media->getType() . ':' . $media->uuid(), $media->getName(), 'Default name was not used correctly by getName().'); + $this->assertEquals('media:' . $media->bundle() . ':' . $media->uuid(), $media_source->getMetadata($media, 'default_name'), 'Value of the default name metadata attribute does not look correct.'); + $this->assertEquals('media:' . $media->bundle() . ':' . $media->uuid(), $media->getName(), 'Default name was not used correctly by getName().'); $this->assertEquals($media->getName(), $media->label(), 'Default name and label are not the same.'); $media->save(); - $this->assertEquals('media:' . $media->getType() . ':' . $media->uuid(), $media->getName(), 'Default name was not saved correctly.'); + $this->assertEquals('media:' . $media->bundle() . ':' . $media->uuid(), $media->getName(), 'Default name was not saved correctly.'); $this->assertEquals($media->getName(), $media->label(), 'The label changed during save.'); // Make sure that the user-supplied name is used. @@ -40,7 +40,7 @@ public function testDefaultName() { ]); $media_source = $media->getSource(); $this->assertEquals('default_name', $media_source->getPluginDefinition()['default_name_metadata_attribute'], 'Default metadata attribute is not used for the default name.'); - $this->assertEquals('media:' . $media->getType() . ':' . $media->uuid(), $media_source->getMetadata($media, 'default_name'), 'Value of the default name metadata attribute does not look correct.'); + $this->assertEquals('media:' . $media->bundle() . ':' . $media->uuid(), $media_source->getMetadata($media, 'default_name'), 'Value of the default name metadata attribute does not look correct.'); $media->save(); $this->assertEquals($name, $media->getName(), 'User-supplied name was not set correctly.'); $this->assertEquals($media->getName(), $media->label(), 'The user-supplied name does not match the label.');