I have the following code in a Drupal's 8.2 my_module.module file.
/** * Implements hook_preprocess_page(). * */ function my_module_preprocess_page(&$variables) { if( \Drupal::routeMatch()->getRouteName() == my.route ) doSomething(); } function doSomething(){ //code here }
My intention is to run some code only when the user requests my.route.
Does Drupal have any function like this?
function my_route_preprocess_page(&$variables) { //code here }
Thanks in advance.