You are here

function _cacheflush_advanced_table_row in CacheFlush 8

Same name and namespace in other branches
  1. 7.3 modules/cacheflush_advanced/cacheflush_advanced.module \_cacheflush_advanced_table_row()
  2. 7 cacheflush_advanced/cacheflush_advanced.module \_cacheflush_advanced_table_row()
  3. 7.2 cacheflush_advanced/cacheflush_advanced.module \_cacheflush_advanced_table_row()

Build cacheflush custom settings row form elements.

@staticvar type $table_options Cache services options.

Parameters

array $element: Form element.

int $delta: Row weight.

string $cid: Cache id to delete.

string $bin: Cache service.

1 call to _cacheflush_advanced_table_row()
_cacheflush_advanced_form in modules/cacheflush_advanced/cacheflush_advanced.module
Form alter callback for add/edit cacheflush entity.

File

modules/cacheflush_advanced/cacheflush_advanced.module, line 138
Cacheflush Advanced module.

Code

function _cacheflush_advanced_table_row(array &$element, $delta, $cid = NULL, $bin = NULL) {
  static $table_options;
  if (empty($table_options)) {
    $module_handler = \Drupal::moduleHandler();
    $module_handler
      ->invokeAll('cache_flush');
    foreach (Cache::getBins() as $service_id => $cache_backend) {
      $table_options[$service_id] = $service_id;
    }
    array_unshift($table_options, t("- Select a service -"));
  }
  $element[$delta]['cid'] = [
    '#type' => 'textfield',
    '#default_value' => $cid,
    '#size' => 20,
  ];
  $element[$delta]['table'] = [
    '#type' => 'select',
    '#default_value' => $bin,
    '#options' => $table_options,
  ];
  $element[$delta]['operations'] = [
    '#name' => 'advanced_remove_' . $delta,
    '#type' => 'button',
    '#value' => t('Remove'),
    '#ajax' => [
      'callback' => '_cacheflush_advanced_form_callback',
      'wrapper' => 'cacheflush-advanced-settings-table',
      'method' => 'replace',
      'effect' => 'fade',
    ],
  ];
}