Home ›
Argument 2 passed to hook help() must be an instance of RouteMatchInterfaceArgument 2 passed to hook help() must be an instance of RouteMatchInterface
Submitted by Benjamin Melançon on July 10, 2016 - 1:52pm
I got this error message, that argument two passed to my module's implementation of hook_help() "must be an instance of RouteMatchInterface, instance of Drupal\Core\Routing\CurrentRouteMatch given", and it's a misleading one.
CurrentRouteMatch in fact (unsurprisingly) implements the RouteMatchInterface. The problem was i hadn't actually defined CurrentRouteMatch— i needed to have a use statement at the top of my module (or use the full PSR4 path in the parameter definition of the hook implementation, but i went with the former). Like so:
<?php
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function guts_discuss_resource_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.guts_discuss_resource':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Automatically creates a forum post referencing a resource when a resource is created.') . '</p>';
return $output;
}
}
?>
Comments
Post new comment