Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BundleItemLinks.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
16 
21 {
25  private $linkCollection;
26 
30  private $valueFactory;
31 
36  public function __construct(
37  Collection $linkCollection,
38  ValueFactory $valueFactory
39  ) {
40  $this->linkCollection = $linkCollection;
41  $this->valueFactory = $valueFactory;
42  }
43 
47  public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
48  {
49  if (!isset($value['option_id']) || !isset($value['parent_id'])) {
50  throw new GraphQlInputException(__('"option_id" and "parent_id" values should be specified'));
51  }
52 
53  $this->linkCollection->addIdFilters((int)$value['option_id'], (int)$value['parent_id']);
54  $result = function () use ($value) {
55  return $this->linkCollection->getLinksForOptionId((int)$value['option_id']);
56  };
57 
58  return $this->valueFactory->create($result);
59  }
60 }
__()
Definition: __.php:13
$value
Definition: gender.phtml:16
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52