rt 4.2.14 (#13852)
[freeside.git] / rt / lib / RT / Link.pm
index 0dadc3b..3160d24 100644 (file)
@@ -2,7 +2,7 @@
 #
 # COPYRIGHT:
 #
-# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC
 #                                          <sales@bestpractical.com>
 #
 # (Except where explicitly superseded by other copyright notices)
@@ -558,6 +558,27 @@ sub Serialize {
 
     delete $store{LocalBase}   if $store{Base};
     delete $store{LocalTarget} if $store{Target};
+
+    for my $dir (qw/Base Target/) {
+        my $uri = $self->${\($dir.'URI')};
+        my $object = $self->${\($dir.'Obj')};
+
+        if ($uri->IsLocal) {
+            if ($args{serializer}->Observe(object => $object)) {
+                # no action needed; the object is being migrated
+            }
+            elsif ($args{serializer}{HyperlinkUnmigrated}) {
+                # object is not being migrated; hyperlinkify
+                $store{$dir} = $uri->AsHREF;
+            }
+            else {
+                # object is not being migrated and hyperlinks not desired,
+                # so drop this RT::Link altogether
+                return;
+            }
+        }
+    }
+
     return %store;
 }