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
Namespace
JsonSchemaCode
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;
}