Closed damienbeaufils closed 7 years ago
Hello team!
We need the lang field of DocumentLink to build an url in our LinkResolver.
DocumentLink
LinkResolver
We had to use reflection to expose this field:
public class PrismicLinkResolver extends SimpleLinkResolver { @Override public String resolve(DocumentLink link) { String lang = getLang(link); String type = link.getType(); String uid = link.getUid(); return "/" + lang + "/" + type + "/" + uid; } private String getLang(DocumentLink link) { try { Field field = ReflectionUtils.findField(DocumentLink.class, "lang", String.class); field.setAccessible(true); return (String) field.get(link); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } }
We would prefer a simple lang getter, instead of using reflection. This PR exposes DocumentLink's lang field.
This PR depends on #56
Thanks and happy hacktoberfest!
Hello team!
We need the lang field of
DocumentLink
to build an url in ourLinkResolver
.We had to use reflection to expose this field:
We would prefer a simple lang getter, instead of using reflection. This PR exposes DocumentLink's lang field.
This PR depends on #56
Thanks and happy hacktoberfest!