-
-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unsupported semicolon prefix in LinkGenerator::link calls #255
Comments
Leading LinkGenerator may simply trim leading |
Thank you @mabar I have just discovered that I actually need the leading Still, are you suggesting that I should trim the |
You're welcome. |
Okay, so we have several people who have encountered this inconsistency spread across several versions (several years between the mentioned issues) and now we have a PR that deals with the issue, is test covered and fixes the issue with performance cost of one Sidenote: May I point out that both
It's missing the leading semicolon option. |
My personal opinion is, if there should be only one syntax allowed, then LinkGenerator should accept only links with leading colon and deprecate syntax without it. |
For me, the deal breaker is this call, that fails. It's one of those WTF moments I would like to avoid. (new LinkGenerator(...))->link($presenter->getAction(true)); |
public function getPresenterClass(string &$name): string
{
if (str_starts_with($name, ':')) {
$name = substr($name, 1);
}
return parent::getPresenterClass($name);
}
Edit: It of course works only in combination with presenter factory... |
I think LinkGenerator shoukd accept both formats. It is unnecessarily annoying to use two different formats for absolute paths or convert them. Especially when same value needs to be used in both presenter and link generator. |
I prepare links in different place than I later call @dg Could you please reconsider the closing of #92 or at least share your thoughts on why you have declined it? Thank you. My usage: // SomePresenter:
public static function linkParams(Id $id, Version $version): array
{
return [':Some:default', [
'id' => $id,
'version' => $version,
]];
}
// AnotherPresenter:
$this->link(...SomePresenter::linkParams($id, $version)); // ok
// Component or other non-presenter context:
$this->linkGenerator->link(...SomePresenter::linkParams($id, $version)); // error |
So annoying to come to this notification to see a 3.5 years old issue still unresolved. |
Version: 3.0.4
Links with destination in deprecated/invalid format
:Module:Presenter:action
(note the semicolon:
at the beginning of the destination string)work with
UI\Presenter
/UI\Component
but not withLinkGenerator
.I'm not sure which one is the desired behaviour, or whether this is a bug of
UI\Component
orLinkGenerator
class, but in the following scenario, only the first call works:The second call fails with
Presenter name must be alphanumeric string, ':Foo:Bar' is invalid.
.Links in the correct format work with both classes, of course ✔:
I understand that the format is not correct according to current documentation, but I would like to point out that the behaviour should be consistent, that is,
it should either work in both cases or not work in either one.
EDIT:
I forgot to add that calling
will result in (depending on whether the presenter is in a module or not)
... which is in direct contradiction to the format, as in the methods' comments:
The text was updated successfully, but these errors were encountered: