Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ReadMain.php
Go to the documentation of this file.
1 <?php
8 
13 
14 class ReadMain
15 {
19  private $typeResolver;
20 
24  private $metadataPool;
25 
29  private $hydratorPool;
30 
34  private $readRow;
35 
42  public function __construct(
43  TypeResolver $typeResolver,
44  MetadataPool $metadataPool,
45  HydratorPool $hydratorPool,
46  ReadRow $readRow
47  ) {
48  $this->typeResolver = $typeResolver;
49  $this->metadataPool = $metadataPool;
50  $this->hydratorPool = $hydratorPool;
51  $this->readRow = $readRow;
52  }
53 
59  public function execute($entity, $identifier)
60  {
61  $entityType = $this->typeResolver->resolve($entity);
62  $hydrator = $this->hydratorPool->getHydrator($entityType);
63  $entityData = $this->readRow->execute($entityType, $identifier);
64  $entity = $hydrator->hydrate($entity, $entityData);
65  return $entity;
66  }
67 }
__construct(TypeResolver $typeResolver, MetadataPool $metadataPool, HydratorPool $hydratorPool, ReadRow $readRow)
Definition: ReadMain.php:42
$entity
Definition: element.phtml:22