You are here

function persian_date_element_info_alter in Persian Date for Drupal 8 8

Same name and namespace in other branches
  1. 8.4 persian_date.module \persian_date_element_info_alter()

Replace form elements with persian ones

Implements hook_element_info_alter().

File

./persian_date.module, line 32
Contains persian_date.module.

Code

function persian_date_element_info_alter(array &$info) {
  $elements = array_intersect_key($info, array_flip([
    'date',
    'datetime',
    'datelist',
  ]));
  foreach ($elements as $name => &$config) {
    if (isset($config['#process'])) {
      foreach ($config['#process'] as &$process) {
        if (is_array($process)) {
          $process[0] = replace_with_equivalent_module_class($process[0]);
        }
      }
    }
    if (isset($config['#pre_render'])) {
      foreach ($config['#pre_render'] as &$process) {
        if (is_array($process)) {
          $process[0] = replace_with_equivalent_module_class($process[0]);
        }
      }
    }
    if (isset($config['#element_validate'])) {
      foreach ($config['#element_validate'] as &$process) {
        if (is_array($process)) {
          $process[0] = replace_with_equivalent_module_class($process[0]);
        }
      }
    }
    if (isset($config['#value_callback'])) {
      if (is_array($config['#value_callback'])) {
        $config['#value_callback'][0] = replace_with_equivalent_module_class($config['#value_callback'][0]);
      }
    }
  }
  $info = array_merge($info, $elements);
}