field_menu.module in Field Menu 8
A menu tree field using the Field Types API.
File
field_menu.moduleView source
<?php
/**
* @file
* A menu tree field using the Field Types API.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function field_menu_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.field_menu':
$readme = __DIR__ . '/README.txt';
$text = file_get_contents($readme);
$output = '';
// If the Markdown module is installed, use it to render the README.
if ($text && \Drupal::moduleHandler()
->moduleExists('markdown') === TRUE) {
$filter_manager = \Drupal::service('plugin.manager.filter');
$settings = \Drupal::configFactory()
->get('markdown.settings')
->getRawData();
$config = [
'settings' => $settings,
];
$filter = $filter_manager
->createInstance('markdown', $config);
$output = $filter
->process($text, 'en');
}
elseif ($text) {
$output = '<pre>' . $text . '</pre>';
}
// Add a link to the Drupal.org project.
$output .= '<p>';
$output .= t('Visit the <a href=":project_link">Field Menu project page</a> on Drupal.org for more information.', [
':project_link' => 'https://www.drupal.org/project/field_menu',
]);
$output .= '</p>';
return $output;
}
}
/**
* Implements hook_theme().
*/
function field_menu_theme() {
return [
'field_menu_item' => [
'variables' => [
'title' => NULL,
'tree' => NULL,
],
],
];
}
Functions
Name | Description |
---|---|
field_menu_help | Implements hook_help(). |
field_menu_theme | Implements hook_theme(). |