/**
  * @param ReferenceValue $reference
  * @param string|null    $context
  * @param Exception|null $previous
  */
 public function __construct(ReferenceValue $reference, $context = null, Exception $previous = null)
 {
     $this->reference = $reference;
     $this->context = $context;
     if (null === $context) {
         $message = sprintf("Unable to resolve reference %s.", var_export($reference->uri()->toString(), true));
     } else {
         $message = sprintf("Unable to resolve reference %s from within context %s.", var_export($reference->uri()->toString(), true), var_export($context, true));
     }
     parent::__construct($message, 0, $previous);
 }
Пример #2
0
 /**
  * @param UriInterface         $referenceUri
  * @param Value\ReferenceValue $reference
  *
  * @return Value\ValueInterface
  * @throws Exception\UndefinedReferenceException
  */
 protected function resolveExternal(UriInterface $referenceUri, Value\ReferenceValue $reference)
 {
     try {
         $value = $this->reader()->read($this->uriFactory()->create($referenceUri->toString()), $reference->mimeType());
     } catch (ReadException $e) {
         throw new Exception\UndefinedReferenceException($reference, $this->currentBaseUri(), $e);
     }
     $this->pushScopeMap($this->scopeMapFactory()->create($referenceUri, $value));
     $value = $value->accept($this);
     $this->popScopeMap();
     $referencePointer = $this->pointerFactory()->createFromUri($referenceUri);
     if ($referencePointer->hasAtoms()) {
         $value = $this->pointerResolver()->resolve($referencePointer, $value);
         if (null === $value) {
             throw new Exception\UndefinedReferenceException($reference, $this->currentBaseUri());
         }
     }
     return $value;
 }