When fetching the object from a routeMatch object, the object is not always filled correctly when fetching it via
$route_match = \Drupal::routeMatch();
$route_match->getParameters(); // or
route_match->getParameter('taxonomy_term');
The parameter 'node' is a full correct object on the following pages in D8.0.0 (but in a previous rc-version, it was not the case):
/node/3
/node/3/delete
/node/3/workflow (using contrib Workflow module) : 'node' => object Drupal\node\Entity\Node(24)
But on the next page, the parameter is not filled with an object.
/taxonomy/term/3 : 'taxonomy_term' => object Drupal\taxonomy\Entity\Term
/taxonomy/term/3/edit : 'taxonomy_term' => object Drupal\taxonomy\Entity\Term
/taxonomy/term/3/workflow : 'taxonomy_term' => string(1) "3"
Below, you find my routing.yml data. Is this a bug? or is something missing? I tested with and without the commented lines - there is no difference.
I did not test this on user or a custom entity type, yet.
entity.node.workflow_history:
path: '/node/{node}/workflow/{field_name}'
defaults:
_title: 'Workflow history'
_controller: '\Drupal\workflow\Controller\WorkflowTransitionListController::historyOverview'
field_name: ~
requirements:
_custom_access: '\Drupal\workflow\Controller\WorkflowTransitionListController::historyAccess'
_module_dependencies: 'node'
# options:
# parameters:
# entity:
# type: entity:{entity_type}
entity.taxonomy_term.workflow_history:
path: '/taxonomy/term/{taxonomy_term}/workflow/{field_name}'
defaults:
_title: 'Workflow history'
_controller: '\Drupal\workflow\Controller\WorkflowTransitionListController::historyOverview'
field_name: ~
requirements:
_custom_access: '\Drupal\workflow\Controller\WorkflowTransitionListController::historyAccess'
_module_dependencies: 'taxonomy'
# taxonomy_term: \d+
# options:
# parameters:
# entity:
# type: entity:{entity_type}
Comments
Comment #2
dawehnerMh, the problem is that those pages are served by Views, mhhhhhhhhh, maybe we need to copy that over when we override it.
Comment #3
rcodina CreditAttribution: rcodina commentedI'm facing a problem which I think is related:
I have a custom module which defines custom breadcrumbs for some views and for nodes of a specific content type. When I try to do the same with taxonomy terms of a specific vocabulary, I'm facing that when I visit "taxonomy/term/%" the applies callback of my custom implementation of BreadcrumbBuilderInterface doesn't get executed. However, it gets called on "taxonomy/term/%/edit". Maybe that's the reason why the core breadcrumb builder only returns "Home / " in this case.
I'm using 8.3.0-beta1 and I hope this get fixed soon. Thanks!
Comment #4
rcodina CreditAttribution: rcodina commentedComment #5
dawehnerSupport questions are way better asked on stackexchange.
Comment #6
rcodina CreditAttribution: rcodina commented@dawehner In my case it's not a support question, it's just a bug report. If you think I should open a new issue just tell me.
Comment #7
rcodina CreditAttribution: rcodina commented@dawehner Question done: http://drupal.stackexchange.com/questions/230722/drupal-8-how-to-do-a-custom-taxonomy-breadcrumb
Comment #8
rcodina CreditAttribution: rcodina commented@dawehner After 14 days there is no answer on stackexchange. Do you think it's a bug?
Comment #9
hugronaphor CreditAttribution: hugronaphor as a volunteer and at Acrosto for Dropsolid commentedThere is an answer which explains that you have to set a higher priority to your service.
https://drupal.stackexchange.com/a/235361/13633