Skip to content

Instantly share code, notes, and snippets.



Last active Sep 17, 2017
What would you like to do?
How can we extend Blade ?
I am using the directive
@url('article_show', ['id' => '3'], ['foo' => 'bar'], 'fragment')
Problem is the rest of the params after string `'article_show'` is not received on call back.
I am trying to do something similar to :
{{ path('article_show', {'id': '3'}) }}
which generates: /article/3
$urlHelperFactory = new UrlHelperFactory();
$urlHelper = $urlHelperFactory($container);
$viewResolver->resolve('blade')->getCompiler()->directive('url', function (
$routeName = null,
array $routeParams = [],
array $queryParams = [],
$fragmentIdentifier = null,
array $options = []
) use ($urlHelper) {
// this works fine
return $urlHelper->generate('article_show', ['id' => '3'], ['foo' => 'bar'], 'fragment');
// this breaks for the params are not received as expected.
// return $urlHelper->generate($routeName, $routeParams, $queryParams, $fragmentIdentifier, $options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment