Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigSetProcessorFactory.php
Go to the documentation of this file.
1 <?php
8 
12 
23 {
30  const TYPE_DEFAULT = 'default';
31 
36  const TYPE_LOCK = 'lock';
37  const TYPE_LOCK_ENV = 'lock-env';
38  const TYPE_LOCK_CONFIG = 'lock-config';
42  private $objectManager;
43 
50  private $processors;
51 
56  public function __construct(
57  ObjectManagerInterface $objectManager,
58  array $processors = []
59  ) {
60  $this->objectManager = $objectManager;
61  $this->processors = $processors;
62  }
63 
73  public function create($processorName)
74  {
75  if (!isset($this->processors[$processorName])) {
77  __('The class for "%1" type wasn\'t declared. Enter the class and try again.', $processorName)
78  );
79  }
80 
81  $object = $this->objectManager->create($this->processors[$processorName]);
82 
83  if (!$object instanceof ConfigSetProcessorInterface) {
85  __('%1 should implement %2', get_class($object), ConfigSetProcessorInterface::class)
86  );
87  }
88 
89  return $object;
90  }
91 }
$objectManager
Definition: bootstrap.php:17
__()
Definition: __.php:13
__construct(ObjectManagerInterface $objectManager, array $processors=[])