Commit 7de29170 authored by Roderik Muit's avatar Roderik Muit Committed by Gábor Hojtsy
Browse files

feat: #3444730 Catch exceptions thrown by config validation to support developers resolving them

By: duckydan
By: robbymo
By: vbouchet
By: idebr
By: roderik
By: dpi
By: dydave
By: golubovicm
By: wim leers
By: gábor hojtsy
By: nevergone
By: tomefa
By: itamair
By: joelpittet
parent 09eeec20
Loading
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ use Drupal\Core\TypedData\Type\DateTimeInterface;
use Drupal\Core\TypedData\Type\DurationInterface;
use Drupal\Core\TypedData\Type\UriInterface;
use Drupal\Core\TypedData\TypedDataInterface;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\ConstraintViolationListInterface;

/**
@@ -333,9 +334,9 @@ class ConfigInspectorManager {
   * @param string $config_name
   *   Configuration name.
   *
   * @return array|bool
   *   FALSE if no schema found. List of errors if any found. TRUE if fully
   *   valid.
   * @return \Symfony\Component\Validator\ConstraintViolationListInterface
   *   A list of constraint violations. If the list is empty, validation
   *   succeeded.
   *
   * @throws \Drupal\Core\Config\Schema\SchemaIncompleteException
   */
@@ -352,7 +353,12 @@ class ConfigInspectorManager {
    // phpcs:disable
    //$typed_config = $this->typedConfigManager->createFromNameAndData($config_name, $config_data);
    // phpcs:enable
    try {
      $violations = $typed_config->validate();
    }
    catch (\Exception $e) {
      $violations = ConstraintViolationList::createFromMessage($e->getMessage());
    }
    return $violations;
  }