objectManager = $objectManager; $this->processors = $processors; } /** * Creates an instance of specified processor. * * @param string $processorName The name of processor * @return ConfigSetProcessorInterface New processor instance * @throws ConfigurationMismatchException If processor type is not exists in processors array * or declared class has wrong implementation * @since 101.0.0 */ public function create($processorName) { if (!isset($this->processors[$processorName])) { throw new ConfigurationMismatchException( __('The class for "%1" type wasn\'t declared. Enter the class and try again.', $processorName) ); } $object = $this->objectManager->create($this->processors[$processorName]); if (!$object instanceof ConfigSetProcessorInterface) { throw new ConfigurationMismatchException( __('%1 should implement %2', get_class($object), ConfigSetProcessorInterface::class) ); } return $object; } }