Return a list of all views and display IDs that have a particular setting in their display's plugin settings.
@endcode
@code array( array($view, $display_id), array($view, $display_id), );
function views_get_applicable_views($type) {
// @todo: Use a smarter flagging system so that we don't have to
// load every view for this.
$result = array();
$views = views_get_all_views();
foreach ($views as $view) {
// Skip disabled views.
if (!$view
->isEnabled()) {
continue;
}
$display = $view
->get('display');
if (empty($display)) {
// Skip this view as it is broken.
continue;
}
// Loop on array keys because something seems to muck with $view->display
// a bit in PHP4.
foreach (array_keys($display) as $id) {
$plugin = drupal_container()
->get('plugin.manager.views.display')
->getDefinition($display[$id]['display_plugin']);
if (!empty($plugin[$type])) {
// This view uses_hook_menu. Clone it so that different handlers
// don't trip over each other, and add it to the list.
$v = $view
->get('executable')
->cloneView();
if ($v
->setDisplay($id) && $v->display_handler
->isEnabled()) {
$result[] = array(
$v,
$id,
);
}
// In PHP 4.4.7 and presumably earlier, if we do not unset $v
// here, we will find that it actually overwrites references
// possibly due to shallow copying issues.
unset($v);
}
}
}
return $result;
}