Return a list of all views and display IDs that have a particular setting in their display's plugin settings.
array(
array(
$view,
$display_id,
),
array(
$view,
$display_id,
),
);
string $type: A flag from the display plugin definitions (e.g, 'uses_hook_menu').
array A list of arrays containing the $view and $display_id.
function views_get_applicable_views($type) {
// Get all display plugins which provides the type.
$display_plugins = Views::pluginManager('display')
->getDefinitions();
$ids = array();
foreach ($display_plugins as $id => $definition) {
if (!empty($definition[$type])) {
$ids[$id] = $id;
}
}
$entity_ids = Drupal::service('entity.query')
->get('view')
->condition('status', TRUE)
->condition("display.*.display_plugin", $ids, 'IN')
->execute();
$result = array();
foreach (Drupal::entityManager()
->getStorageController('view')
->load($entity_ids) as $view) {
// Check each display to see if it meets the criteria and is enabled.
$executable = $view
->get('executable');
$executable
->initDisplay();
foreach ($executable->displayHandlers as $id => $handler) {
if (!empty($handler->definition[$type]) && $handler
->isEnabled()) {
$result[] = array(
$executable,
$id,
);
}
}
}
return $result;
}