Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ReadEntityRow.php
Go to the documentation of this file.
1 <?php
8 
10 
15 {
19  protected $metadataPool;
20 
24  public function __construct(
26  ) {
27  $this->metadataPool = $metadataPool;
28  }
29 
37  public function execute($entityType, $identifier, $context = [])
38  {
39  $metadata = $this->metadataPool->getMetadata($entityType);
40  $select = $metadata->getEntityConnection()->select()
41  ->from(['t' => $metadata->getEntityTable()])
42  ->where($metadata->getIdentifierField() . ' = ?', $identifier);
43  foreach ($context as $field => $value) {
44  $select->where(
45  $metadata->getEntityConnection()->quoteIdentifier($field) . ' = ?',
46  $value
47  );
48  }
49  $data = $metadata->getEntityConnection()->fetchRow($select);
50  return $data ?: [];
51  }
52 }
$value
Definition: gender.phtml:16
execute($entityType, $identifier, $context=[])