@@ -26,6 +26,8 @@ abstract class Filter implements JsonSerializable
2626
2727 public $ relatedRepositoryKey ;
2828
29+ public $ relatedRepositoryTitle ;
30+
2931 public Repository $ repository ;
3032
3133 public function __construct ()
@@ -114,19 +116,31 @@ public function setRelatedRepositoryKey(string $repositoryKey): self
114116 return $ this ;
115117 }
116118
119+ public function setRelatedRepositoryTitle (string $ title ): self
120+ {
121+ $ this ->relatedRepositoryTitle = $ title ;
122+
123+ return $ this ;
124+ }
125+
117126 public function setRepository (Repository $ repository ): self
118127 {
119128 $ this ->repository = $ repository ;
120129
121130 return $ this ;
122131 }
123132
124- public function getRelatedRepositoryUrl (): ?string
133+ public function getRelatedRepository (): ?array
125134 {
126135 return ($ key = $ this ->getRelatedRepositoryKey ())
127136 ? with (Restify::repositoryForKey ($ key ), function ($ repository = null ) {
128137 if (is_subclass_of ($ repository , Repository::class)) {
129- return Restify::path ($ repository ::uriKey ());
138+ return [
139+ 'key ' => $ repository ::uriKey (),
140+ 'url ' => Restify::path ($ repository ::uriKey ()),
141+ 'display_key ' => $ this ->relatedRepositoryTitle ?? $ repository ::$ title ,
142+ 'label ' => $ repository ::label (),
143+ ];
130144 }
131145 })
132146 : null ;
@@ -161,8 +175,7 @@ public function jsonSerialize()
161175 ], function (array $ initial ) {
162176 return $ this ->relatedRepositoryKey
163177 ? array_merge ($ initial , [
164- 'related_repository_key ' => $ this ->getRelatedRepositoryKey (),
165- 'related_repository_url ' => $ this ->getRelatedRepositoryUrl (),
178+ 'repository ' => $ this ->getRelatedRepository (),
166179 ])
167180 : $ initial ;
168181 });
0 commit comments