This documentation is for a version that has reached its End Of Life. Such versions are no longer supported and don't receive security updates. Consider updating to a newer version.
The controller uses the Ancestor Search Criterion to find all Ancestors of the current Location (line 27).
It then places the ancestors in the breadcrumbs variable that you can use in the template.
Next, call this controller from the page layout template and pass the current location ID as a parameter:
Finally, create a breadcrumb template in templates/themes/<theme_name>/parts/breadcrumbs.html.twig, as indicated in the controller (line 34).
In this template, iterate over all breadcrumbs and render links to them: