Issue #3437566 by mondrake, longwave, catch, smustgrave, alexpott: Refactor trigger_error in TypedConfigManager
parent
d265060558
commit
ea5932e490
|
@ -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 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
|
|||
$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);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ use Drupal\Core\TypedData\ComplexDataInterface;
|
|||
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 @@ class TypedConfigTest extends KernelTestBase {
|
|||
$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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue