menu_multilingual.module in Menu Multilingual 8
Enhances the multilingual capabilities for the blocks with menus.
File
menu_multilingual.moduleView source
<?php
/**
* @file
* Enhances the multilingual capabilities for the blocks with menus.
*/
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\menu_multilingual\Helpers;
/**
* Implements hook_block_view_BASE_BLOCK_ID_alter().
*/
function menu_multilingual_block_view_system_menu_block_alter(array &$build) {
Helpers::setBlockProcessing($build);
}
/**
* Implements hook_block_view_BASE_BLOCK_ID_alter().
*/
function menu_multilingual_block_view_menu_block_alter(array &$build) {
Helpers::setBlockProcessing($build);
}
/**
* Implements hook_form_FORM_ID_alter().
*
* Applied for language_content_settings_form().
*/
function menu_multilingual_form_language_content_settings_form_alter(array &$form, FormStateInterface $form_state) {
if (in_array('content_translation_form_language_content_settings_submit', $form['#submit'])) {
$form['#submit'][] = [
'Drupal\\menu_multilingual\\Helpers',
'languageContentSettingsSubmit',
];
}
}
/**
* Implements hook_module_implements_alter().
*/
function menu_multilingual_module_implements_alter(&$implementations, $hook) {
if ($hook == 'form_language_content_settings_form_alter') {
$group = $implementations['menu_multilingual'];
unset($implementations['menu_multilingual']);
$implementations['menu_multilingual'] = $group;
}
}
/**
* Implements hook_block_alter().
*/
function menu_multilingual_block_alter(&$definitions) {
foreach ($definitions as $key => $definition) {
if (substr($key, 0, 18) == 'system_menu_block:') {
$definitions[$key]['class'] = 'Drupal\\menu_multilingual\\Plugin\\Block\\SystemMenuBlockMultilingual';
}
if (substr($key, 0, 11) == 'menu_block:') {
$definitions[$key]['class'] = 'Drupal\\menu_multilingual\\Plugin\\Block\\MenuBlockMultilingual';
}
}
}
/**
* Implements hook_help().
*/
function menu_multilingual_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.menu_multilingual':
$text = file_get_contents(dirname(__FILE__) . '/README.md');
if (!\Drupal::moduleHandler()
->moduleExists('markdown')) {
return '<pre>' . $text . '</pre>';
}
else {
// Use the Markdown filter to render the README.
$filter_manager = \Drupal::service('plugin.manager.filter');
$settings = \Drupal::configFactory()
->get('markdown.settings')
->getRawData();
$config = [
'settings' => $settings,
];
$filter = $filter_manager
->createInstance('markdown', $config);
return $filter
->process($text, 'en');
}
}
return NULL;
}
Functions
Name | Description |
---|---|
menu_multilingual_block_alter | Implements hook_block_alter(). |
menu_multilingual_block_view_menu_block_alter | Implements hook_block_view_BASE_BLOCK_ID_alter(). |
menu_multilingual_block_view_system_menu_block_alter | Implements hook_block_view_BASE_BLOCK_ID_alter(). |
menu_multilingual_form_language_content_settings_form_alter | Implements hook_form_FORM_ID_alter(). |
menu_multilingual_help | Implements hook_help(). |
menu_multilingual_module_implements_alter | Implements hook_module_implements_alter(). |