use Drupal\Core\Routing\RouteMatchInterface; /** * Implements hook_menu(). */ function my_module_menu() { $items['my/module/custom/path'] = array( 'page callback' => 'my_module_page_callback', 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); return $items; } function my_module_page_callback() { $route_match = \Drupal::routeMatch(); if ($route_match instanceof RouteMatchInterface) { $node = $route_match->getParameter('node'); // Do something with the node object. } }In this example, the custom path "my/module/custom/path" is defined as a new route using `hook_menu()`. The `my_module_page_callback()` function is called when this route is accessed. Within this function, the `routeMatch()` function is used to get the current route match object. The `getParameter()` function is then used to get any parameters passed in the URL, in this case, the node object. This example uses the Drupal Core package library.