factoryMapByConfigElementType = $factoryMapByConfigElementType; } /** * Instantiate config element based on its type specified in $data * * @param array $data * @return ConfigElementInterface */ public function createFromConfigData(array $data): ConfigElementInterface { if (!isset($this->factoryMapByConfigElementType[$data['type']])) { throw new \LogicException( sprintf('Factory is not configured for config element of "%s" type', $data['type']) ); } return $this->factoryMapByConfigElementType[$data['type']]->createFromConfigData($data); } }