Verified Commit ea5932e4 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3437566 by mondrake, longwave, catch, smustgrave, alexpott: Refactor...

Issue #3437566 by mondrake, longwave, catch, smustgrave, alexpott: Refactor trigger_error in TypedConfigManager
parent d2650605
Loading
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Drupal\Core\Config;

use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\Schema\ConfigSchemaAlterException;
@@ -83,10 +82,7 @@ public function get($name) {
    $data = $this->configStorage->read($name);
    if ($data === FALSE) {
      // For a typed config the data MUST exist.
      $data = [];
      trigger_error(new FormattableMarkup('Missing required data for typed configuration: @config', [
        '@config' => $name,
      ]), E_USER_ERROR);
      throw new \InvalidArgumentException("Missing required data for typed configuration: $name");
    }
    return $this->createFromNameAndData($name, $data);
  }
+1 −2
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@
use Drupal\Core\TypedData\Type\IntegerInterface;
use Drupal\Core\TypedData\Type\StringInterface;
use Drupal\KernelTests\KernelTestBase;
use PHPUnit\Framework\Error\Error;
use Symfony\Component\Validator\ConstraintViolationListInterface;

/**
@@ -53,7 +52,7 @@ public function testTypedDataAPI() {
      $typed_config_manager->get('config_test.non_existent');
      $this->fail('Expected error when trying to get non-existent typed config.');
    }
    catch (Error $e) {
    catch (\InvalidArgumentException $e) {
      $this->assertEquals('Missing required data for typed configuration: config_test.non_existent', $e->getMessage());
    }