From 44aae8c1a1112cfdbed5cea49431b23c42490b62 Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Tue, 16 Jul 2013 15:24:11 -0400 Subject: [PATCH] Ensure expand context URL option is processed. --- jsonld.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/jsonld.php b/jsonld.php index 3afabb6..bf09718 100644 --- a/jsonld.php +++ b/jsonld.php @@ -796,6 +796,16 @@ class JsonLdProcessor { 'document' => self::copy($input), 'remoteContext' => (object)array( '@context' => $remote_doc->contextUrl)); + if(isset($options['expandContext'])) { + $expand_context = self::copy($options['expandContext']); + if(is_object($expand_context) && + property_exists($expand_context, '@context')) { + $input->expandContext = $expand_context; + } + else { + $input->expandContext = (object)array('@context' => $expand_context); + } + } // retrieve all @context URLs in the input try { @@ -813,13 +823,15 @@ class JsonLdProcessor { $remote_context = $input->remoteContext->{'@context'}; // process optional expandContext - if(isset($options['expandContext'])) { - self::_processContext($active_ctx, $options->expandContext, $options); + if(property_exists($input, 'expandContext')) { + $active_ctx = self::_processContext( + $active_ctx, $input->expandContext, $options); } // process remote context from HTTP Link Header if($remote_context) { - self::_processContext($active_ctx, $remote_context, $options); + $active_ctx = self::_processContext( + $active_ctx, $remote_context, $options); } // do expansion