Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MediaGalleryEntries.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
15 
20 {
26  public function resolve(
27  Field $field,
28  $context,
30  array $value = null,
31  array $args = null
32  ) {
33  if (!isset($value['model'])) {
34  throw new GraphQlInputException(__('"model" value should be specified'));
35  }
36 
38  $product = $value['model'];
39 
40  $mediaGalleryEntries = [];
41  if (!empty($product->getMediaGalleryEntries())) {
42  foreach ($product->getMediaGalleryEntries() as $key => $entry) {
43  $mediaGalleryEntries[$key] = $entry->getData();
44  if ($entry->getExtensionAttributes() && $entry->getExtensionAttributes()->getVideoContent()) {
45  $mediaGalleryEntries[$key]['video_content']
46  = $entry->getExtensionAttributes()->getVideoContent()->getData();
47  }
48  }
49  }
50  return $mediaGalleryEntries;
51  }
52 }
__()
Definition: __.php:13
$value
Definition: gender.phtml:16
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52
resolve(Field $field, $context, ResolveInfo $info, array $value=null, array $args=null)