Skip to content
Snippets Groups Projects

Resolve "Introduce PSR-4 autoloading"

Merged Stein Magne Bjorklund requested to merge 12-introduce-psr-4-autoloading into master
1 file
+ 10
15
Compare changes
  • Side-by-side
  • Inline
@@ -139,13 +139,11 @@ class ServiceModule extends abstractModule
$context = array();
$context['contentType'] = $acceptContentType;
$context['endpoints'] = $endpoints;
//$f = $this->getFunction($localUri);
$params = $this->getParams($localUri);
//$params[] = $context;
//$acceptContentType = Utils::getBestContentType($_SERVER['HTTP_ACCEPT']);
$extension = Utils::getExtension($acceptContentType, $conf['http_accept']);
$args = array();
list($modelFile, $viewFile) = $service;
try {
$prefixHeader = array();
@@ -160,7 +158,6 @@ class ServiceModule extends abstractModule
$segmentConnector = "";
for ($i = 0; $i < sizeof($params); $i++) {
Utils::curie2uri($params[$i]);
//echo $params[$i]." ".Utils::curie2uri($params[$i]);exit(0);
$auxPrefix = Utils::getPrefix($params[$i]);
if ($auxPrefix['ns'] != null) {
$prefixHeader[] = $auxPrefix;
@@ -186,7 +183,6 @@ class ServiceModule extends abstractModule
$lodspk['local']['curie'] = Utils::uri2curie($localUri);
$lodspk['contentType'] = $acceptContentType;
$lodspk['endpoint'] = $conf['endpoint'];
$lodspk['type'] = $modelFile;
$lodspk['header'] = $prefixHeader;
$lodspk['args'] = $args;
@@ -196,13 +192,12 @@ class ServiceModule extends abstractModule
if ($viewFile == null) {
$lodspk['transform_select_query'] = true;
}
// chdir($lodspk['model']);
Utils::queryFile($modelFile, $endpoints['local'], $results, $firstResults);
if (!$lodspk['resultRdf']) {
$results = Utils::internalize($results);
$firstAux = Utils::getfirstResults($results);
// chdir($conf['home']);
if (is_array($results)) {
$resultsObj = Convert::array_to_object($results);
$results = $resultsObj;
@@ -213,9 +208,7 @@ class ServiceModule extends abstractModule
} else {
$resultsObj = $results;
}
//Need to redefine viewFile as 'local' i.e., inside service.foo/ so I can load files with the relative path correctly
//$viewFile = $extension.".template";
//chdir($conf['home']);
Utils::processDocument($viewFile, $lodspk, $results);
} catch (Exception $ex) {
echo $ex->getMessage();
@@ -233,17 +226,17 @@ class ServiceModule extends abstractModule
$count = 1;
$prefixUri = $conf['basedir'];
$functionAndParams = explode('/', str_replace($prefixUri . $lodspk['serviceName'], '', $uri, $count));
if (sizeof($functionAndParams) > 1) {
array_shift($functionAndParams);
return $functionAndParams;
} else {
return array(null);
}
return array(null);
}
protected function readScaffold($scaffold, $serviceArgs)
{
global $conf;
$parser = ARC2::getTurtleParser();
$parser->parse($scaffold);
$triples = $parser->getTriples();
@@ -253,19 +246,21 @@ class ServiceModule extends abstractModule
);
$scaffoldUri = $aux[0][0];
$aux = Utils::filterTriples($triples, array($scaffoldUri, "http://lodspeakr.org/vocab/scaffold", null));
foreach ($aux as $r) {
$patterns = Utils::filterTriples($triples, array($r[2], "http://lodspeakr.org/vocab/uriPattern", null));
$pattern = stripcslashes($patterns[0][2]);
if (preg_match("|$pattern|", $serviceArgs) > 0) {
// echo "match ! \n ".$pattern."\n";
$patternDir = Utils::filterTriples(
$triples,
array($r[2], "http://lodspeakr.org/vocab/subComponent", null)
);
return $patternDir[0][2];
}
}
// exit(0);
return "";
}
Loading