@@ -60,6 +60,11 @@ function get_apib($filename)
60
60
$ this ->get_apib ($ this ->location . $ value . '.apib ' ), $ file );
61
61
}
62
62
63
+ preg_match_all ('<!-- schema\(([a-z0-9_.\/\:]*?)\) --> ' , $ file , $ matches );
64
+ foreach ($ matches [1 ] as $ value ) {
65
+ $ file = str_replace ('<!-- schema( ' . $ value . ') --> ' , $ this ->get_schema ($ value ), $ file );
66
+ }
67
+
63
68
return $ file ;
64
69
}
65
70
@@ -72,13 +77,31 @@ function get_apib($filename)
72
77
*/
73
78
private function file_check ($ filename )
74
79
{
75
- if (!file_exists ($ filename ))
76
- {
80
+ if (!file_exists ($ filename )) {
77
81
file_put_contents ('php://stderr ' , "API File not found: $ filename \n" );
78
82
exit (1 );
79
83
}
80
84
}
81
85
86
+ /**
87
+ * Get an external Schema by URL
88
+ *
89
+ * @param string $url URL to fetch the schema from
90
+ *
91
+ * @return string The schema as a string
92
+ */
93
+ function get_schema ($ url )
94
+ {
95
+ $ ch = curl_init ();
96
+ curl_setopt ($ ch , CURLOPT_URL , $ url );
97
+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
98
+ curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , 1 );
99
+ $ result = curl_exec ($ ch );
100
+ curl_close ($ ch );
101
+
102
+ return $ result ;
103
+ }
104
+
82
105
/**
83
106
* Return the value of the class
84
107
*
0 commit comments