Hot answers tagged

1

You need to give the router a nudge towards what $politician is supposed to be for the automatic up-casting to kick in. There are two ways to do that: Type-hint the variable in the controller method: function build(Politician $politician) { See EntityResolverManager::setParametersFromReflection for details Explicitly set the parameter type in the route ...


1

I guess you need to do a route parameter upcasting: entity.politician.about_me: path: '/politician/{politician}/about-me' defaults: _controller: '\Drupal\pw_basic\Controller\PoliticianFrontend\AboutMe::build' _title_callback: '\Drupal\pw_basic\Controller\PoliticianFrontend\AboutMe::title' requirements: _entity_access: 'politician.view' ...


1

DynamicRoutesAlter.php Problem #1 - preg_replace() without pattern $url = preg_replace('_', '-', $key); The $url will be always NULL, because you are using preg_replace() without regexp, use instead str_replace() or write appropriate regexp pattern: '/_/'. Solution #1 $url = preg_replace('/_/', '-', $key); Solution #2 $url = str_replace('_', '-', $key)...


Only top voted, non community-wiki answers of a minimum length are eligible