The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Hot answers tagged

5

The dash is not the problem, you could use a dash in the fixed part, but ... Unlike generic Symfony routes, Drupal requires that a slug occupies a complete path part - the portion between two slashes (or everything after the last slash). https://www.drupal.org/docs/8/api/routing-system/parameters-in-routes/using-parameters-in-routes Alternatively ...


3

The reason why you get that error is because run is not expected to be called statically. \Drupal\Core\Cron is a service class managed by Drupal, registered in core.services.yml. To get a reference to the instance of this service, you'll need to inject the dependency to your controller. namespace Drupal\mymodule\Controller; use Drupal\Core\Controller\...


1

Implement the redirect in a module. Either in a kernel request subscriber, see this change record https://www.drupal.org/node/2013014 or in a kernel response subscriber, see https://git.drupalcode.org/project/age_verification/blob/8.x/src/EventSubscriber/pathGate.php. The second example is from a contrib module you can try as it is. I don't have first-hand ...


1

The order doesn't matter, routes are stored indexed by name. The first and the second route have a different component count, so they can't interfere. The second route gets priority over the third, because it has one more fixed component. So in this case the route matching doesn't need any complex calculations. In general route matching rarely affects ...


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