Skip to content
Snippets Groups Projects

Issue #3514886 by just_like_good_vibes: Site error when enabled on Drupal CMS

Merged Mikael Meulle requested to merge issue/ui_patterns-3514886:3514886-site-error-when into 2.0.x
4 files
+ 38
9
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -5,7 +5,9 @@ declare(strict_types=1);
namespace Drupal\ui_patterns\SchemaManager;
use JsonSchema\Constraints\BaseConstraint;
use JsonSchema\Exception\RuntimeException;
use JsonSchema\SchemaStorage;
use Psr\Log\LoggerInterface;
/**
* JSON Schema References resolver.
@@ -18,6 +20,14 @@ class ReferencesResolver {
const MAXIMUM_RECURSIVITY_LEVEL = 10;
/**
* Constructs a ComponentElementBuilder.
*/
public function __construct(
protected LoggerInterface $logger,
) {
}
/**
* Resolve schema references recursively.
*/
@@ -28,7 +38,17 @@ class ReferencesResolver {
$depth = $depth + 1;
$schema = BaseConstraint::arrayToObjectRecursive($schema);
$storage = new SchemaStorage();
$schema = (array) $storage->resolveRefSchema($schema);
try {
$schema = (array) $storage->resolveRefSchema($schema);
}
catch (RuntimeException $e) {
$schema = (array) $schema;
$this->logger->error(t("Could not resolve schema referenced by \$ref property '@ref': @error", [
"@ref" => $schema['$ref'] ?? '',
"@error" => $e->getMessage(),
]));
}
foreach ($schema as $key => $value) {
if (!is_object($value)) {
continue;
Loading