Short description of what this feature will allow to do:
A breadcrumb or breadcrumb trail is a graphical control element used as a navigational aid in user interfaces and on web pages. It allows users to keep track and maintain awareness of their locations within programs, documents, or websites. The term is a reference to the trail of bread crumbs left by Hansel and Gretel in the German fairy tale of the same name.[1]
Example of how to use this feature
To enable breadcrumbs at once and in all modules, you only need to add literally only one function call, the rest will happen completely automatically:
// src/Controller/DashboardController.php
class DashboardController extends AbstractDashboardController
{
public function configureDashboard(): Dashboard
{
return Dashboard::new()
->enableBreadcrumb() // <== The Magic Is HERE
// or change 'Home' to something else:
// ->enableBreadcrumb('Admin')
// or for i18n set translation key
// ->enableBreadcrumb('admin_label.breadcrumb.home')
...
;
}
}
Sometimes it is necessary to change the algorithm for generating breadcrumbs. For example, there is a child controller, which is responsible for displaying the details of the object associated with the main object. In this case it is necessary for breadcrumb to be built from the main object. To do this, there is a special way to specify a custom callback function that allows you to change the logic of breadcrumb generation. In the example below, the counterparty has a list of FTS checks, each of which can be viewed in detail on a separate page using the child controller ContractorFnsInfoCrudController.
Occasionally you need to prepend some contextual link to the current breadcrumb. For example, in the list of payments you want to add a link to a very frequently used report for easy navigation of users. Or, on the other hand, you want to add a backlink to the list of payments in this report. You can achieve this functionality by using custom PHP attribute BreadcrumbItem on the target controller. Attributes have the highest priority when generating breadcrumbs. The example below shows just such a case.
// src/Controller/PaymentCrudController.php
class PaymentCrudController extends AbstractCrudController
{
/**
* The Index
*/
#[BreadcrumbItem(action: 'stat', label: 'admin_label.payment.page.stat')]
public function index(AdminContext $context): KeyValueStore|Response
{
return parent::index($context);
}
/**
* The Report
*/
#[BreadcrumbItem(label: 'admin_label.menu.item.reports', route: 'app_report')]
#[BreadcrumbItem(action: Action::INDEX)]
public function stat(): Response
{
if (!$this->isGranted(Permission::EA_EXECUTE_ACTION, ['action' => Action::INDEX, 'entity' => null])) {
throw $this->createAccessDeniedException();
}
/** @var ProjectRepository $repo */
$repo = $this->em->getRepository(Project::class);
return $this->render('@Ksn135Company/payment-stat.html.twig', [
'ea_field_assets' => new AssetsDto(),
'action_page_title' => 'admin_label.payment.page.stat',
'rows' => $repo->getRowsForStatPage(),
]);
}
}
I will be glad to hear the opinion of the community
Short description of what this feature will allow to do:
Example of how to use this feature
To enable breadcrumbs at once and in all modules, you only need to add literally only one function call, the rest will happen completely automatically:
Sometimes it is necessary to change the algorithm for generating breadcrumbs. For example, there is a child controller, which is responsible for displaying the details of the object associated with the main object. In this case it is necessary for breadcrumb to be built from the main object. To do this, there is a special way to specify a custom callback function that allows you to change the logic of breadcrumb generation. In the example below, the counterparty has a list of FTS checks, each of which can be viewed in detail on a separate page using the child controller
ContractorFnsInfoCrudController
.Occasionally you need to prepend some contextual link to the current breadcrumb. For example, in the list of payments you want to add a link to a very frequently used report for easy navigation of users. Or, on the other hand, you want to add a backlink to the list of payments in this report. You can achieve this functionality by using custom PHP attribute
BreadcrumbItem
on the target controller. Attributes have the highest priority when generating breadcrumbs. The example below shows just such a case.I will be glad to hear the opinion of the community