Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OperationPool.php
Go to the documentation of this file.
1 <?php
8 
15 
20 {
24  private $defaultOperations = [
25  'checkIfExists' => CheckIfExists::class,
26  'read' => Read::class,
27  'create' => Create::class,
28  'update' => Update::class,
29  'delete' => Delete::class,
30  ];
31 
35  private $operations;
36 
40  private $objectManager;
41 
47  public function __construct(
48  ObjectManager $objectManager,
49  $operations = []
50  ) {
51  $this->objectManager = $objectManager;
52  $this->operations = array_replace_recursive(
53  ['default' => $this->defaultOperations],
54  $operations
55  );
56  }
57 
65  public function getOperation($entityType, $operationName)
66  {
67  if (!isset($this->operations[$entityType][$operationName])) {
68  return $this->objectManager->get($this->operations['default'][$operationName]);
69  }
70  return $this->objectManager->get($this->operations[$entityType][$operationName]);
71  }
72 }
$objectManager
Definition: bootstrap.php:17
getOperation($entityType, $operationName)
__construct(ObjectManager $objectManager, $operations=[])