Closed robinvdvleuten closed 9 years ago
It would change the API, right?
Yeah a little bit, but you can do it without conflicts when you change the method to something like;
public function getBestFormat($acceptHeader, array $priorities = array(), $defaultValue = null) {
And change the return value null
to $defaultValue
. This way, anyone already using the method won't have to change their code.
But by further looking into the FormatNegotiation class, I see that by giving / as Accept header the code returns the first priority value. Maybe I can use that as some sort of default value.
@RobinvdVleuten what about introducing a getBestFormatOrElse()
method?
This is a "wontfix" as Negotiation 2.0 does not contain this method anymore.
Hi William,
Is it possible to add functionality to return a default format instead of null when calling
getBestFormat()
. If you like the idea, I can submit a PR for it.Cheers, Robin