You are here

public function AssetMediaFactory::get in Media: Acquia DAM 8

Wrap a media entity with a helper to enable asset functionality.

Parameters

\Drupal\media\MediaInterface $media: The media entity to wrap.

Return value

\Drupal\media_acquiadam\MediaEntityHelper A media entity wrapped with a helper class.

File

src/Service/AssetMediaFactory.php, line 244

Class

AssetMediaFactory
Class AssetMediaFactory.

Namespace

Drupal\media_acquiadam\Service

Code

public function get(MediaInterface $media) {

  // Not ideal but the usage of media_acquiadam.asset_file.helper gets flagged
  // as a circular dependency even though it's just a passthrough to another
  // class.
  // phpcs:disable DrupalPractice.Objects.GlobalDrupal.GlobalDrupal
  $container = \Drupal::getContainer();

  // phpcs:enable
  $helper_class = $this
    ->getAssetMediaEntityHelperClass();
  return new $helper_class($media, $this->entityTypeManager, $container
    ->get('media_acquiadam.asset_data'), $container
    ->get('media_acquiadam.acquiadam'), $container
    ->get('media_acquiadam.asset_file.helper'));
}