@@ -60,6 +60,11 @@ function get_apib($filename)
6060 $ this ->get_apib ($ this ->location . $ value . '.apib ' ), $ file );
6161 }
6262
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+
6368 return $ file ;
6469 }
6570
@@ -72,13 +77,31 @@ function get_apib($filename)
7277 */
7378 private function file_check ($ filename )
7479 {
75- if (!file_exists ($ filename ))
76- {
80+ if (!file_exists ($ filename )) {
7781 file_put_contents ('php://stderr ' , "API File not found: $ filename \n" );
7882 exit (1 );
7983 }
8084 }
8185
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+
82105 /**
83106 * Return the value of the class
84107 *
0 commit comments