We can search all the default views on our relatively new Drupal 8 site, to see what view resides at a particular path, with a query like:
$view_trim_path = 'blog';
$query = $this->entityQuery->get('view')
->condition('display.page_1.display_options.path', $view_trim_path)
Unfortunately, this relies upon a hardcoded display name of page_1
, which will not hold true in general. In my dreams I would use a wildcard query like
->condition('display.page*.display_options.path', ...)
Is there a way to do either of the following?
- create a set of entityQuery conditions to find views that have
display.*.display_options.path
equal to a certain value, no matter what the value of*
... preferably when*
begins with thepage_
prefix - use another Drupal / View function to look up a view ID from its path (I can't find one)
I can see how to find this by loading the config entities for all views and traversing all those arrays, but my guess is that Drupal has provided a simpler means for this. Also it seems the database abstraction layer would be of use, and if that's the best practice then it would really help me to have an example of how to use it for the above query.
*
will look for N depth between display and display_options, and there should only be 1 anyway. I think you would want all results anyway because any view that has a path is going to be relevant for your search. Also the operator forcondition
can be changed toSTARTS_WITH
, which could be helpful.