Simplify term definition creation, disallow @type in property generator.
This commit is contained in:
parent
b7cf6df479
commit
5c5ab819d7
20
jsonld.php
20
jsonld.php
|
@ -4147,19 +4147,17 @@ class JsonLdProcessor {
|
|||
$property_generator = array();
|
||||
$ids = $id;
|
||||
foreach($ids as $id) {
|
||||
if(!is_string($id)) {
|
||||
if(!is_string($id) || $id === '@type') {
|
||||
throw new JsonLdException(
|
||||
'Invalid JSON-LD syntax; property generators must consist of ' .
|
||||
'an @id array containing only strings.',
|
||||
'an @id array containing only strings and no string can be ' .
|
||||
'"@type".',
|
||||
'jsonld.SyntaxError', array('context' => $local_ctx));
|
||||
}
|
||||
// expand @id if it is not @type
|
||||
if($id !== '@type') {
|
||||
$id = $this->_expandIri(
|
||||
// expand @id
|
||||
$property_generator[] = $this->_expandIri(
|
||||
$active_ctx, $id, array('base' => true), $local_ctx, $defined);
|
||||
}
|
||||
$property_generator[] = $id;
|
||||
}
|
||||
// add sorted property generator as @id in mapping
|
||||
sort($property_generator);
|
||||
$mapping->{'@id'} = $property_generator;
|
||||
|
@ -4172,14 +4170,10 @@ class JsonLdProcessor {
|
|||
'jsonld.SyntaxError', array('context' => $local_ctx));
|
||||
}
|
||||
else {
|
||||
// add @id to mapping, expanding it if it is not @type
|
||||
if($id !== '@type') {
|
||||
// expand @id to full IRI
|
||||
$id = $this->_expandIri(
|
||||
// add @id to mapping
|
||||
$mapping->{'@id'} = $this->_expandIri(
|
||||
$active_ctx, $id, array('base' => true), $local_ctx, $defined);
|
||||
}
|
||||
$mapping->{'@id'} = $id;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if($prefix === null) {
|
||||
|
|
Loading…
Reference in a new issue