How do I expose display routes from a specific view as REST API? I have set up some displays in a Categories view, all with their own path. I want to expose all displays from that view with a REST API.
I've already set up a module with a path, but how do I get the paths to the individual displays?
$view = Views::getView('categories'); gives me the view (probably with my desired displays), but I am quite stuck there.
Most of the answers I find online are pretty much outdated.
I actually found a solution which is working for me myself.
$view = Views::getView('categories');

$displays = $view-&gt;storage-&gt;get('display');

$ret = array();

foreach( $displays as $display){
  array_push($ret, array(
    'title'   =&gt; $display['display_title'],
    'path'    =&gt; $display['display_options']['path']
  ));
}

return new JsonResponse( $ret );