You are here

function ccl_features_rebuild in Custom Contextual Links 8

Same name and namespace in other branches
  1. 7 ccl.features.inc \ccl_features_rebuild()

Implements hook_features_rebuild().

Rebuilds Custom Contextual Links from code defaults.

1 call to ccl_features_rebuild()
ccl_features_revert in ./ccl.features.inc
Implements hook_features_revert().

File

./ccl.features.inc, line 78
Integrates Features for Custom Contextual Links.

Code

function ccl_features_rebuild($module) {
  $presets = \Drupal::moduleHandler()
    ->invoke($module, 'ccl_features_preset');
  foreach ($presets as $key => $preset) {
    $preset = (object) $preset;
    $current_record = current(ccl_get_presets($key));
    if (!empty($current_record)) {
      $preset->clid = $current_record->clid;
      \Drupal::database()
        ->merge('ccl')
        ->fields($preset)
        ->key([
        'clid',
      ])
        ->execute();
    }
    else {
      \Drupal::database()
        ->insert('ccl')
        ->fields($preset)
        ->execute();
    }
  }
}