public function __construct(Xref $xref, $message = "", $code = 0, \Exception $previous = null)
 {
     if ($xref->hasLocation()) {
         $message = sprintf('Unable to fetch external reference of type "%s" from location "%s"%s.', $xref->getType(), $xref->getLocation(), $message == '' ? '' : ': ' . $message);
     } else {
         $message = sprintf('Unable to fetch external reference of type "%s": no location specified.', $xref->getType());
     }
     parent::__construct($message, $code, $previous);
 }
 public function __construct(Xref $xref, $message = "", $code = 0, \Exception $previous = null)
 {
     if ($xref->hasLocation()) {
         $message = sprintf("Error resolving Xref of type \"%s\" from location \"%s\"%s", $xref->getType(), $xref->getLocation(), $message == '' ? '' : ': ' . $message);
     }
     parent::__construct($message, $code, $previous);
 }
 /**
  * Used internally to verify if this Xref has the same type as the given Xref.
  *
  * @param Xref $xref The Xref to compare to.
  * @throws InvalidXrefTypeException
  */
 protected static function matchType(Xref $xref)
 {
     if ($xref->getType() !== static::getType()) {
         throw new InvalidXrefTypeException(sprintf('%s is unable to resolve Xrefs of type %s.', get_called_class(), $xref->getType()));
     }
 }
Beispiel #4
0
 public function remove(Xref $xref)
 {
     try {
         $this->removeById($xref->getId());
     } catch (\Exception $e) {
         if (strpos($e->getMessage(), $xref->getId())) {
             throw new \Exception(sprintf('Xref of type "%s" with location "%s" not in collection.', $xref->getType(), $xref->getLocation()));
         }
         throw $e;
     }
 }