View source
<?php
namespace Drupal\menu_multilingual;
use Drupal\block\BlockInterface;
use Drupal\Core\Form\FormStateInterface;
class Helpers {
public static function setBlockProcessing(&$build) {
$settings = $build['#configuration'];
if (!empty($settings['only_translated_labels']) || !empty($settings['only_translated_content'])) {
$modifier = \Drupal::service('menu_multilingual.modifier');
$modifier
->filterLabels($settings['only_translated_labels']);
$modifier
->filterContent($settings['only_translated_content']);
$build['#pre_render'][] = [
$modifier,
'filterLinksInRenderArray',
];
}
}
public static function saveBlockSettings($entity_type, BlockInterface $block, &$form, FormStateInterface $form_state) {
$settings = $form_state
->getValue([
'settings',
'multilingual',
]);
$elements = $form['settings']['multilingual'];
if ($elements['only_translated_labels']['#disabled']) {
$settings['only_translated_labels'] = FALSE;
}
if ($elements['only_translated_content']['#disabled']) {
$settings['only_translated_content'] = FALSE;
}
$block
->setThirdPartySetting('menu_multilingual', 'only_translated_labels', $settings['only_translated_labels']);
$block
->setThirdPartySetting('menu_multilingual', 'only_translated_content', $settings['only_translated_content']);
}
public static function checkEntityType($type) {
$translationManager = \Drupal::service('content_translation.manager');
return $translationManager
->isEnabled($type);
}
public static function languageContentSettingsSubmit() {
}
}