By admin, 26 March, 2024 Get user (id) from URL $user = \Drupal::routeMatch()->getParameter('user'); Tags user routes
By admin, 20 December, 2023 Disable cache for controller page Add this code to routeoptions: no_cache: TRUE Tags cache controller routes
By admin, 4 May, 2023 Inject RouteMatchInterface to ContentEntityForm use Drupal\Core\Routing\RouteMatchInterface; /** * The current route match. * * @var \Drupal\Core\Routing\RouteMatchInterface */ protected $routeMatch; /** * Constructs a PrivatemsgMessageForm object. * * @param \Drupal\Core\En Tags dependency injection routes
By admin, 1 March, 2023 Redirect user if view page /** * Implements hook_preprocess_HOOK(). */ function EXAMPLE_preprocess_page(&$variables) { $route_name = \Drupal::routeMatch()->getRouteName(); if ($route_name == 'entity.user.canonical') { $current_user = \Drupal::currentUser(); $roles = $current_user->getRoles(); if Tags routes redirect
By admin, 24 February, 2023 Get current route $route_name = \Drupal::routeMatch()->getRouteName(); Tags routes