Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SchemaStorage.php

function SchemaStorage::resolveRef

Overrides SchemaStorageInterface::resolveRef

1 call to SchemaStorage::resolveRef()
SchemaStorage::resolveRefSchema in vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php
Returns schema referenced by '$ref' property

File

vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php, line 124

Class

SchemaStorage

Namespace

JsonSchema

Code

public function resolveRef($ref) {
    $jsonPointer = new JsonPointer($ref);
    // resolve filename for pointer
    $fileName = $jsonPointer->getFilename();
    if (!strlen($fileName)) {
        throw new UnresolvableJsonPointerException(sprintf("Could not resolve fragment '%s': no file is defined", $jsonPointer->getPropertyPathAsString()));
    }
    // get & process the schema
    $refSchema = $this->getSchema($fileName);
    foreach ($jsonPointer->getPropertyPaths() as $path) {
        if (is_object($refSchema) && property_exists($refSchema, $path)) {
            $refSchema = $this->resolveRefSchema($refSchema->{$path});
        }
        elseif (is_array($refSchema) && array_key_exists($path, $refSchema)) {
            $refSchema = $this->resolveRefSchema($refSchema[$path]);
        }
        else {
            throw new UnresolvableJsonPointerException(sprintf('File: %s is found, but could not resolve fragment: %s', $jsonPointer->getFilename(), $jsonPointer->getPropertyPathAsString()));
        }
    }
    return $refSchema;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal