You are here

function taxonomy_post_update_configure_status_field_widget in Drupal 8

Add status with settings to all form displays for taxonomy entities.

File

core/modules/taxonomy/taxonomy.post_update.php, line 351
Post update functions for Taxonomy.

Code

function taxonomy_post_update_configure_status_field_widget(&$sandbox = NULL) {
  \Drupal::classResolver(ConfigEntityUpdater::class)
    ->update($sandbox, 'entity_form_display', function (EntityDisplayInterface $entity_form_display) {

    // Only update taxonomy term entity form displays with no existing options
    // for the status field.
    if ($entity_form_display
      ->getTargetEntityTypeId() == 'taxonomy_term' && empty($entity_form_display
      ->getComponent('status'))) {
      $entity_form_display
        ->setComponent('status', [
        'type' => 'boolean_checkbox',
        'settings' => [
          'display_label' => TRUE,
        ],
      ]);
      return TRUE;
    }
    return FALSE;
  });
}