Skip to content

Commit 061e3c4

Browse files
author
Thomas Jarrand
committed
Fix url_add shortcut
1 parent c4353d0 commit 061e3c4

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

Menu/Builder.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function isCurrentRoute(?string $route): bool
8686
return $this->getCurrentAttribute('_route') === $route;
8787
}
8888

89-
public function addParametersToCurrentUrl(array $parameters, int $referenceType = null): string
89+
public function addParametersToCurrentUrl(array $parameters, int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH): string
9090
{
9191
return $this->urlGenerator->generate(
9292
$this->getCurrentAttribute('_route'),
@@ -99,6 +99,15 @@ public function addParametersToCurrentUrl(array $parameters, int $referenceType
9999
);
100100
}
101101

102+
public function getCurrentUrl(int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH): string
103+
{
104+
return $this->urlGenerator->generate(
105+
$this->getCurrentAttribute('_route'),
106+
$this->getCurrentAttribute('_route_params'),
107+
$referenceType
108+
);
109+
}
110+
102111
/**
103112
* Get attribute from current request
104113
*

Twig/Extensions/MenuExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function getFunctions(): array
2121
return [
2222
new TwigFunction('menu_path', [$this->builder, 'getMenuPath']),
2323
new TwigFunction('url_add', [$this->builder, 'addParametersToCurrentUrl']),
24+
new TwigFunction('url_current', [$this->builder, 'getCurrentUrl']),
2425
];
2526
}
2627

0 commit comments

Comments
 (0)