Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ArgumentApplierPool.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 
16 {
18  private $appliers = [];
19 
23  private $objectManager;
24 
29  public function __construct(
30  ObjectManagerInterface $objectManager,
31  array $appliers = [
32  ArgumentApplier\Filter::ARGUMENT_NAME => ArgumentApplier\Filter::class,
33  ArgumentApplier\Sort::ARGUMENT_NAME => ArgumentApplier\Sort::class
34  ]
35  ) {
36  $this->objectManager = $objectManager;
37  $this->appliers = $appliers;
38  }
39 
47  public function getApplier(string $argumentName) : ArgumentApplierInterface
48  {
49  if (isset($this->appliers[$argumentName])) {
50  return $this->objectManager->get($this->appliers[$argumentName]);
51  } else {
52  throw new \LogicException(sprintf('Applier %s not found', $argumentName));
53  }
54  }
55 
62  public function hasApplier(string $argumentName) : bool
63  {
64  if (isset($this->appliers[$argumentName])) {
65  return true;
66  } else {
67  return false;
68  }
69  }
70 }
$objectManager
Definition: bootstrap.php:17
__construct(ObjectManagerInterface $objectManager, array $appliers=[ArgumentApplier\Filter::ARGUMENT_NAME=> ArgumentApplier\Filter::class, ArgumentApplier\Sort::ARGUMENT_NAME=> ArgumentApplier\Sort::class])