Closed tremby closed 10 years ago
Some of the other kits actually already work like that (including the Ruby kit), and I think it is a good idea, and we should probably synchronize all the kits around that behavior.
Do you need it quickly? This is basic PHP, so, with proper code review from @dohzya, I should be able to make that happen. (or if you'd rather give it a go, knock yourself out, we'd happily merge it!)
I actually started to implement the changes but making it work the same way as the Ruby meant turning the LinkInterface into an abstract Link class, and I realized I then wasn't going to have time to finish, or to write tests.
There's no big rush but it'd definitely be nice to see.
One question: isBroken
is decided by Prismic before we get our hands on the data, right? But should a link be treated as if it's broken in the same way (i.e. a span element) if the link resolver returns null
/false
? There may be cases where the application may want to decide if a link is valid or not based on context, even if it's valid as far as Prismic is concerned.
See the pull request. I did not refactor to make it more like the Ruby kit -- this is a pretty simple change.
It might be useful for the HTML renderer not to print the
<a>
tag at all (only its contents) if theLinkResolver
'sresolve
method (or the closure) returnsnull
(orfalse
or something), rather than having an<a href="">
tag when a link can't be made for whatever reason.It'd be more useful again to be able to change the tag which is used (a
<span class="broken-link">
or something, perhaps) in certain cases, rather than being limited to only changing thehref
.Just an idea, since if a link is broken at the moment I can raise a warning but am otherwise stuck with an
<a href="">click here to whatever</a>
element. Something for the "someday" list, perhaps.