Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ReadAttributes.php
Go to the documentation of this file.
1 <?php
7 
11 
16 {
20  private $typeResolver;
21 
25  private $hydratorPool;
26 
30  private $attributePool;
31 
37  public function __construct(
38  TypeResolver $typeResolver,
39  HydratorPool $hydratorPool,
40  AttributePool $attributePool
41  ) {
42  $this->typeResolver = $typeResolver;
43  $this->hydratorPool = $hydratorPool;
44  $this->attributePool = $attributePool;
45  }
46 
52  public function execute($entity, $arguments = [])
53  {
54  $entityType = $this->typeResolver->resolve($entity);
55  $hydrator = $this->hydratorPool->getHydrator($entityType);
56  $entityData = array_merge($hydrator->extract($entity), $arguments);
57  $actions = $this->attributePool->getActions($entityType, 'read');
58  foreach ($actions as $action) {
59  $entityData = array_merge($entityData, $action->execute($entityType, $entityData, $arguments));
60  }
61  $entity = $hydrator->hydrate($entity, $entityData);
62  return $entity;
63  }
64 }
__construct(TypeResolver $typeResolver, HydratorPool $hydratorPool, AttributePool $attributePool)
$entity
Definition: element.phtml:22
$arguments