Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EntryConverterPool.php
Go to the documentation of this file.
1 <?php
8 
16 {
20  private $mediaGalleryEntryConvertersCollection;
21 
25  public function __construct(array $mediaGalleryEntryConvertersCollection)
26  {
27  foreach ($mediaGalleryEntryConvertersCollection as $converter) {
28  if (!$converter instanceof EntryConverterInterface) {
29  throw new \InvalidArgumentException(
30  __('Media Gallery converter should be an instance of EntryConverterInterface.')
31  );
32  }
33  }
34  $this->mediaGalleryEntryConvertersCollection = $mediaGalleryEntryConvertersCollection;
35  }
36 
44  public function getConverterByMediaType($mediaType)
45  {
46  foreach ($this->mediaGalleryEntryConvertersCollection as $converter) {
47  if ($converter->getMediaEntryType() == $mediaType) {
48  return $converter;
49  }
50  }
51  throw new \Magento\Framework\Exception\LocalizedException(
52  __('There is no MediaGalleryEntryConverter for given type')
53  );
54  }
55 }
__construct(array $mediaGalleryEntryConvertersCollection)
getConverterByMediaType($mediaType)
__()
Definition: __.php:13