slope-it / breadcrumb-bundle

A bundle for generating dynamic breadcrumbs in Symfony applications
Other
10 stars 4 forks source link

Allow parsing multiple parameters #15

Closed Jupi007 closed 2 years ago

Jupi007 commented 2 years ago

Allow parsing multiple parameters and adding static string in labels:

#[Breadcrumb(['label' => 'Galerie $gallery.title - $gallery.year'])]

Will render something like:

Galerie vacance - 2021

Shouldn't do any BC break.

Closes #7, #9

asprega commented 2 years ago

Hi, thanks for your PR. I see a problem with this approach and i18n, though: handling mixed dynamic and static components in the label creates ambiguity as to what to do with translation of static parts. Should I treat them as translatable labels or not? In your examples, you're assuming you don't want to translate but this is not generally true for all projects.

My suggestion, when you need to do something complex like the example you provided, is to just inject BreadcrumbBuilder in your controller and build your label dynamically there, as explained in the documentation: https://github.com/slope-it/breadcrumb-bundle#2-define-breadcrumbs

Jupi007 commented 2 years ago

No problem, I totally understand this. Indeed, in my app, I don't need to use i18n, so I didn't think about this problematic.

I'll follow your suggestion, it's indeed more logical :+1: