Skip to content

Commit 8ecffb6

Browse files
committed
Add root path to Validator, to be able to use the draft-07.json from package
1 parent 0cfbf1a commit 8ecffb6

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Validator.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function validate(): bool
123123
$this->schema instanceof Json => $resolver->registerRaw($this->schema->getJsonStringFormatted(), Constants::ID_JSON_SCHEMA_GENERAL)
124124
};
125125

126-
$resolver->registerFile(Constants::URL_JSON_SCHEMA_DRAFT_07, (new File(Constants::PATH_SCHEMA_DRAFT_07, $this->pathRoot))->getPathReal());
126+
$resolver->registerFile(Constants::URL_JSON_SCHEMA_DRAFT_07, (new File(Constants::PATH_SCHEMA_DRAFT_07, $this->pathRoot ?: $this->getRootPath()))->getPathReal());
127127

128128
$data = match (true) {
129129
$this->data instanceof File => $this->getJsonDecoded($this->data->getContentAsJson()->getJsonStringFormatted()),
@@ -231,4 +231,14 @@ public function getStatusJson(): string
231231
{
232232
return (new Json($this->getStatusArray()))->getJsonStringFormatted();
233233
}
234+
235+
/**
236+
* Returns the root path of this class.
237+
*
238+
* @return string
239+
*/
240+
private function getRootPath(): string
241+
{
242+
return dirname(__FILE__, 2);
243+
}
234244
}

0 commit comments

Comments
 (0)