protected function EasyRdfConverter::createGraph in Schema.org configuration tool (RDF UI) 8
Creates an \EasyRdf\Graph object from the given URI.
Parameters
string $uri: URL of a web resource or path of the cached file.
string $type: Format of the document.
Throws
\InvalidArgumentException If invalid type or URL is passed as parameters.
1 call to EasyRdfConverter::createGraph()
File
- src/
EasyRdfConverter.php, line 53
Class
- EasyRdfConverter
- Extracts details of RDF resources from an RDFa document.
Namespace
Drupal\rdfuiCode
protected function createGraph($uri, $type) {
/*
* Initialize an EasyRdf_Graph object using
* _construct(string $uri = null, string $data = null,
* string $format = null)
*/
if (!is_string($type) or $type == NULL or $type == '') {
throw new \InvalidArgumentException("\$type should be a string and cannot be null or empty");
}
if (!is_string($uri) or $uri == NULL or $uri == '') {
throw new \InvalidArgumentException("\$uri should be a string and cannot be null or empty");
}
try {
if (preg_match('#^http#i', $uri) === 1) {
$this->graph = new Graph($uri, NULL, $type);
$this->graph
->load();
}
else {
$this->graph = new Graph(NULL);
$this->graph
->parseFile($uri);
}
$this
->iterateGraph();
} catch (\Exception $e) {
throw new \InvalidArgumentException("Invalid uri + {$e}");
}
}