8 - How do a get a view then save it with a new value In an update_hook() I need to search all views' displays for a value, then resave them with a new/extra one.  How do I go about this?  What command can I use?

$views = Views::getEnabledViews();
foreach ($views as $view) {
  $source_value = '';
  $config = \Drupal::config('views.view.' . $view-&gt;id());
  $rawData = $config-&gt;getRawData();

  $master = FALSE;
  // Get the display with the draggableviews field.
  // It is a little tricky because the 'default' display is the master.
  foreach ($rawData['display'] as $display_key =&gt; $display) {
    $field = isset($display['display_options']['fields']) ? $display['display_options']['fields'] : [];
    if ($display_key == 'default' &amp;&amp; array_key_exists('draggableviews', $field)) {
      $master = TRUE;
    }
    if ($display_key != 'default' &amp;&amp; array_key_exists('draggableviews', $field)) {
      $source_value = $view-&gt;id() . '|' . $display_key;
    }
    if ($master &amp;&amp; empty($display['display_options']['fields'])) {
      $source_value = $view-&gt;id() . '|' . $display_key;
    }
  }
  if ($source_value) {
    // Save the view with the source value in the sort handler.
    foreach ($rawData['display'] as $display_key =&gt; $display) {
      $sorts = isset($display['display_options']['sorts']) ? $display['display_options']['sorts'] : [];
      if (array_key_exists('weight', $sorts)) {
        // **************
        // SAVE VIEW HERE
        // **************
      }
    }
  }
}
Replace 

// **************
// SAVE VIEW HERE
// **************


with

$view_exec = Views::getView($view-&gt;id());
$view_exec-&gt;setHandlerOption($display_key, 'sort', 'weight', 'source', $source_value);
$view_exec-&gt;save();


When you call Views::getEnabledViews() it gives you an array of View classes.  What you need is the ViewsExecutable class.   Views::getView($id) returns this.

ViewsExecutable


  An object to contain all of the data to generate a view, plus the member functions to build the view query, execute the query and render the output.


Views vs ViewsExecutable

Another good example of using setHandlerOptions is in the TestCase

FieldGroupRowTest