You are here

protected function PanelsDisplayManager::validate in Panels 8.4

Same name and namespace in other branches
  1. 8.3 src/PanelsDisplayManager.php \Drupal\panels\PanelsDisplayManager::validate()

Validates the config against the schema.

Parameters

array $config: The configuration data.

Throws

\Exception If the configuration doesn't validate.

1 call to PanelsDisplayManager::validate()
PanelsDisplayManager::importDisplay in src/PanelsDisplayManager.php
Creates a panels display from exported configuration.

File

src/PanelsDisplayManager.php, line 60

Class

PanelsDisplayManager
A service that manages Panels displays.

Namespace

Drupal\panels

Code

protected function validate(array $config) {
  $this->configName = 'display_variant.plugin.panels_variant';
  $definition = $this->typedConfigManager
    ->getDefinition($this->configName);
  $data_definition = $this->typedConfigManager
    ->buildDataDefinition($definition, $config);
  $this->schema = $this->typedConfigManager
    ->create($data_definition, $config);
  $errors = array();
  foreach ($config as $key => $value) {
    $errors = array_merge($errors, $this
      ->checkValue($key, $value));
  }
  if (!empty($errors)) {
    $error_list = [];
    foreach ($errors as $key => $error) {
      $error_list[] = $key . ': ' . $error;
    }
    throw new \Exception("Config for Panels display doesn't validate: " . implode(', ', $error_list));
  }
}