select2_all.module in Select2 ALL THE THINGS! 8
Hooks for the Select2 All module.
File
select2_all.moduleView source
<?php
/**
* @file
* Hooks for the Select2 All module.
*/
use Drupal\Core\Form\FormStateInterface;
use Drupal\select2_all\Select2;
/**
* Implements hook_element_info_alter().
*/
function select2_all_element_info_alter(&$info) {
$info['select']['#pre_render'][] = [
Select2::class,
'preRenderSelect',
];
if (isset($info['date_combo'])) {
//$info['date_combo']['#pre_render'][] = [Select2::class, 'preRenderDateCombo'];
}
if (isset($info['select_or_other'])) {
//$info['select_or_other']['#pre_render'][] = [Select2::class, 'preRenderSelectOrOther'];
}
if (isset($info['synonyms_entity_select'])) {
$info['synonyms_entity_select']['#pre_render'][] = [
Select2::class,
'preRenderSelect',
];
}
}
/**
* Implements hook_field_widget_form_alter().
*
* @see \Drupal\select2_all\Select2::preRenderSelect()
*/
function select2_all_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {
/** @var \Drupal\Core\Field\FieldDefinitionInterface $field_definition */
$field_definition = $context['items']
->getFieldDefinition();
$element['#entity_type'] = $field_definition
->getTargetEntityTypeId();
$element['#bundle'] = $field_definition
->getTargetBundle();
}
/**
* Implements hook_library_info_alter().
*/
function select2_all_library_info_alter(array &$libraries, $extension) {
if ($extension === 'select2_all' && is_dir(DRUPAL_ROOT . '/libraries/select2/dist')) {
unset($libraries['select2']['js']);
unset($libraries['select2']['css']);
unset($libraries['select2']['version']);
$libraries['select2']['js']['/libraries/select2/dist/js/select2.min.js'] = [
'minified' => TRUE,
];
$libraries['select2']['css']['component']['/libraries/select2/dist/css/select2.min.css'] = [
'minified' => TRUE,
];
}
}
Functions
Name | Description |
---|---|
select2_all_element_info_alter | Implements hook_element_info_alter(). |
select2_all_field_widget_form_alter | Implements hook_field_widget_form_alter(). |
select2_all_library_info_alter | Implements hook_library_info_alter(). |