@@ -11,18 +11,23 @@ class Preloaded implements RemoteRefProvider
1111{
1212 private $ storage ;
1313
14- private $ cachePaths = array (
15- 'http://json-schema.org/draft-04/schema ' => __DIR__ . '/../../spec/json-schema.json ' ,
16- 'http://json-schema.org/draft-06/schema ' => __DIR__ . '/../../spec/json-schema-draft6.json ' ,
17- 'http://json-schema.org/draft-07/schema ' => __DIR__ . '/../../spec/json-schema-draft7.json ' ,
18- );
14+ private $ schemaFiles ;
15+
16+ public function __construct ()
17+ {
18+ $ this ->schemaFiles = array (
19+ 'http://json-schema.org/draft-04/schema ' => __DIR__ . '/../../spec/json-schema.json ' ,
20+ 'http://json-schema.org/draft-06/schema ' => __DIR__ . '/../../spec/json-schema-draft6.json ' ,
21+ 'http://json-schema.org/draft-07/schema ' => __DIR__ . '/../../spec/json-schema-draft7.json ' ,
22+ );
23+ }
1924
2025 public function getSchemaData ($ url )
2126 {
2227 if (isset ($ this ->storage [$ url ])) {
2328 return $ this ->storage [$ url ];
24- } elseif (isset ($ this ->cachePaths [$ url ])) {
25- $ this ->storage [$ url ] = json_decode (file_get_contents ($ this ->cachePaths [$ url ]));
29+ } elseif (isset ($ this ->schemaFiles [$ url ])) {
30+ $ this ->storage [$ url ] = json_decode (file_get_contents ($ this ->schemaFiles [$ url ]));
2631 return $ this ->storage [$ url ];
2732 }
2833 return false ;
@@ -56,5 +61,11 @@ public function setSchemaData($url, $schemaData)
5661 return $ this ;
5762 }
5863
64+ public function setSchemaFile ($ url , $ path )
65+ {
66+ $ this ->schemaFiles [$ url ] = $ path ;
67+ return $ this ;
68+ }
69+
5970
6071}
0 commit comments