checkValue example

$configuration_name = sprintf("ckeditor5.plugin.%s", $this->id);
      // TRICKY: SchemaCheckTrait::checkConfigSchema() dynamically adds a       // 'langcode' key-value pair that is irrelevant here. Also,       // ::checkValue() may (counter to its docs) trigger an exception.       $this->configName = 'STRIP';
      $this->schema = $this->getTypedConfig()->createFromNameAndData($configuration_name$configuration);
    }

    $schema_errors = [];
    foreach ($configuration as $key => $value) {
      try {
        $schema_error = $this->checkValue($key$value);
      }
      catch (\InvalidArgumentException $e) {
        $schema_error = [$key => $e->getMessage()];
      }
      $schema_errors = array_merge($schema_errors$schema_error);
    }
    $formatted_schema_errors = [];
    foreach ($schema_errors as $key => $value) {
      $formatted_schema_errors[] = sprintf("[%s] %s", str_replace('STRIP:', '', $key)trim($value, '.'));
    }
    if (!empty($formatted_schema_errors)) {
      
    // the data if it doesn't already exist.     if (!isset($config_data['langcode'])) {
      $config_data['langcode'] = 'en';
    }
    $this->configName = $config_name;
    if (!$typed_config->hasConfigSchema($config_name)) {
      return FALSE;
    }
    $this->schema = $typed_config->createFromNameAndData($config_name$config_data);
    $errors = [];
    foreach ($config_data as $key => $value) {
      $errors[] = $this->checkValue($key$value);
    }
    $errors = array_merge(...$errors);
    if (empty($errors)) {
      return TRUE;
    }
    return $errors;
  }

  /** * Helper method to check data type. * * @param string $key * A string of configuration key. * @param mixed $value * Value of given key. * * @return array * List of errors found while checking with the corresponding schema. */
Home | Imprint | This part of the site doesn't use cookies.