File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 *
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments