Change Views Path Programatically I have a custom form on my site, and on submission, I'd like to update a Views page path.

Within my module, I have a form alter which eventually attaches a custom submit function where I plan to run this Views path change. Within my submit function, so far I have:

function _my_module_custom_submit() {
    $view = \Drupal\views\Views::getView('custom_view');
    $view-&gt;setDisplay('page_1');
    // TODO: Change Views path

    // Save View
    $view-&gt;save();
}


This function is running fine, however I cannot find how to change the Views Display path at all. I've tried the setHandler() and setHandlerOption() methods, but these don't appear to be working for this case.

I've found plenty of examples to change the Views path programatically in Drupal 7, but have yet to come across an example for Drupal 8.
In Drupal 8 the configuration of a View is stored in an entity, which you can load, modify and save:

use Drupal\views\Entity\View;

  $view = View::load('custom_view');
  $display =&amp; $view-&gt;getDisplay('page_1');
  $display['display_options']['path'] = 'example/path';
  $view-&gt;save();