Skip to content
Snippets Groups Projects
Commit 6323f98c authored by Angie Byron's avatar Angie Byron
Browse files

Issue #1900962 by damiankloip, tim.plunkett, dawehner: Use Config Entity query...

Issue #1900962 by damiankloip, tim.plunkett, dawehner: Use Config Entity query for views_get_applicable_views().
parent 56580a39
No related branches found
No related tags found
No related merge requests found
......@@ -1101,7 +1101,11 @@ function views_get_enabled_display_extenders() {
* Return a list of all views and display IDs that have a particular
* setting in their display's plugin settings.
*
* @return
* @param string $type
* A flag from the display plugin definitions (e.g, 'uses_hook_menu').
*
* @return array
* A list of arrays containing the $view and $display_id.
* @code
* array(
* array($view, $display_id),
......@@ -1110,32 +1114,34 @@ function views_get_enabled_display_extenders() {
* @endcode
*/
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();
$container = drupal_container();
foreach ($views as $view) {
// Skip disabled views.
if (!$view->isEnabled()) {
continue;
// Get all display plugins which provides the type.
$display_plugins = $container->get('plugin.manager.views.display')->getDefinitions();
$ids = array();
foreach ($display_plugins as $id => $definition) {
if (!empty($definition[$type])) {
$ids[$id] = $id;
}
}
$display = $view->get('display');
if (empty($display)) {
// Skip this view as it is broken.
continue;
}
$entity_ids = $container->get('entity.query')->get('view')
->condition('disabled', FALSE)
->condition("display.*.display_plugin", $ids, 'IN')
->execute();
$result = array();
foreach ($container->get('plugin.manager.entity')->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->setDisplay();
$executable->initDisplay();
foreach ($executable->displayHandlers as $id => $handler) {
if (!empty($handler->definition[$type]) && $handler->isEnabled()) {
$result[] = array($executable, $id);
}
}
}
return $result;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment