You are here

function tablefield_post_update_implement_tablefield_entity_view_display_schema in TableField 8.2

Resave entity view display config to apply the tablefield schema changes.

File

./tablefield.post_update.php, line 38
Post update functions for tablefield.

Code

function tablefield_post_update_implement_tablefield_entity_view_display_schema(&$sandbox = NULL) {
  \Drupal::classResolver(ConfigEntityUpdater::class)
    ->update($sandbox, 'entity_view_display', function (EntityViewDisplayInterface $entityViewDisplay) {
    $updated = FALSE;
    foreach ($entityViewDisplay
      ->getComponents() as $key => $component) {
      if ($component['type'] === 'tablefield') {
        $component['settings']['row_header'] = (bool) $component['settings']['row_header'];
        $component['settings']['column_header'] = (bool) $component['settings']['column_header'];
        $entityViewDisplay
          ->setComponent($key, $component);
        $updated = TRUE;
      }
    }
    return $updated;
  });
}