You are here

protected function AssertMediaTrait::assertIsMediaEntity in Gutenberg 8

Same name and namespace in other branches
  1. 8.2 src/AssertMediaTrait.php \Drupal\gutenberg\AssertMediaTrait::assertIsMediaEntity()

Assert if provided entity is type of MediaInterface.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: Entity instance to check.

Throws

\Exception

1 call to AssertMediaTrait::assertIsMediaEntity()
MediaEntityRenderer::render in src/MediaEntityRenderer.php
Render media entities.

File

src/AssertMediaTrait.php, line 38

Class

AssertMediaTrait
Provides utility to assert data.

Namespace

Drupal\gutenberg

Code

protected function assertIsMediaEntity(ContentEntityInterface $entity) {
  if (!$entity instanceof MediaInterface) {
    throw new \Exception(sprintf('Entity must by type of %s.', MediaInterface::class));
  }
}