You are here

public function Update200::renameMediaOverviewTypeFilter in Lightning Media 8.2

Same name and namespace in other branches
  1. 8.4 src/Update/Update200.php \Drupal\lightning_media\Update\Update200::renameMediaOverviewTypeFilter()
  2. 8.3 src/Update/Update200.php \Drupal\lightning_media\Update\Update200::renameMediaOverviewTypeFilter()

Renames the Media overview page's Source filter.

@update

@ask Do you want to rename the "Media Type" filter label on the Media overview page to "Type"? This will also change the filter's URL identifier to 'type' and will make the label and URL identifier consistent with new installs of Lightning.

File

src/Update/Update200.php, line 61

Class

Update200
Plugin annotation @Update("2.0.0");

Namespace

Drupal\lightning_media\Update

Code

public function renameMediaOverviewTypeFilter() {
  $view = $this->configFactory
    ->getEditable('views.view.media');
  if ($view
    ->isNew()) {
    return;
  }
  $property = 'display.default.display_options.filters.bundle';
  $filter = $view
    ->get($property);
  if ($filter) {
    $filter['expose']['label'] = 'Type';
    $filter['expose']['identifier'] = 'type';
    $view
      ->set($property, $filter)
      ->save();
  }
}