mhujer / BreadcrumbsBundle

Breadcrumbs bundle for Symfony. This is a fork of whiteoctober/BreadcrumbsBundle maintained for newer Symfony and PHP versions.
Other
66 stars 12 forks source link

Configure breadcrumb via PHP attributes? #33

Open knallcharge opened 2 years ago

knallcharge commented 2 years ago

I was wondering if it was possible to also configure the breadcrumbs using PHP attributes (like the breadcrumbtrai-bundle by APY does it).

You'd have slimmer method headers in controllers, less code in the methods (as the configuration is already done in the attribute) and wouldn't have to inject the breadcrumb-service. e.g.

#[Breadcrumb(title: 'Home', routeName: IndexController::ROUTE_OVERVIEW)]
#[Breadcrumb(title: 'Page')]

If you need to inject custom values into the breadcrumb in the controller (for me only about 5% of the cases I use breadcrumbs), you could still use the injection (like it is now).

mhujer commented 2 years ago

@Knallcharge Hi, thanks for the issue! I probably personally won't use this feature, but I'd happy to accept a PR which adds it (if it comes with tests 😉).

knallcharge commented 2 years ago

I'll check it out, if I find the time (or if APY doesn't come with an update for symfony 6).