You are here

function content_browser_update_8002 in Content Browser 8

Updates the content browser view to contextually filter by allowed bundles.

File

./content_browser.install, line 135
Defines install routines for Content Browser.

Code

function content_browser_update_8002() {

  /** @var \Drupal\views\Entity\View $view */
  if (($view = View::load('content_browser')) && class_exists('Drupal\\entity_browser\\Plugin\\views\\argument_default\\EntityBrowserWidgetContext')) {
    $display =& $view
      ->getDisplay('default');
    $display['display_options']['arguments']['type'] = [
      'id' => 'type',
      'table' => 'node_field_data',
      'field' => 'type',
      'relationship' => 'none',
      'group_type' => 'group',
      'admin_label' => '',
      'default_action' => 'default',
      'exception' => [
        'value' => 'all',
        'title_enable' => FALSE,
        'title' => 'All',
      ],
      'title_enable' => FALSE,
      'title' => '',
      'default_argument_type' => 'entity_browser_widget_context',
      'default_argument_options' => [
        'context_key' => 'target_bundles',
        'fallback' => 'all',
        'multiple' => 'or',
      ],
      'default_argument_skip_url' => FALSE,
      'summary_options' => [
        'base_path' => '',
        'count' => TRUE,
        'items_per_page' => 25,
        'override' => FALSE,
      ],
      'summary' => [
        'sort_order' => 'asc',
        'number_of_records' => 0,
        'format' => 'default_summary',
      ],
      'specify_validation' => FALSE,
      'validate' => [
        'type' => 'none',
        'fail' => 'not found',
      ],
      'validate_options' => [],
      'glossary' => FALSE,
      'limit' => 0,
      'case' => 'none',
      'path_case' => 'none',
      'transform_dash' => FALSE,
      'break_phrase' => TRUE,
      'entity_type' => 'node',
      'entity_field' => 'type',
      'plugin_id' => 'node_type',
    ];
    $view
      ->save();
  }
}