Commit 8e855ad1 authored by damiankloip's avatar damiankloip Committed by tim.plunkett

Issue #1794144 by damiankloip, tim.plunkett: Clean up and fix views.drush.inc.

parent e127cd6d
This diff is collapsed.
<?php
/**
* @file
* Contains the view analyze tool code.
*/
use Drupal\views\Analyzer;
/**
* Implements hook_views_analyze().
*
* This is the basic views analysis that checks for very minimal problems.
* There are other analysis tools in core specific sections, such as
* node.views.inc as well.
*/
function views_ui_views_analyze($view) {
$ret = array();
// Check for something other than the default display:
if (count($view->display) < 2) {
$ret[] = Analyzer::formatMessage(t('This view has only a default display and therefore will not be placed anywhere on your site; perhaps you want to add a page or a block display.'), 'warning');
}
// You can give a page display the same path as an alias existing in the
// system, so the alias will not work anymore. Report this to the user,
// because he probably wanted something else.
foreach ($view->displayHandlers as $display) {
if (empty($display)) {
continue;
}
if ($display->hasPath() && $path = $display->getOption('path')) {
$normal_path = drupal_get_normal_path($path);
if ($path != $normal_path) {
$ret[] = Analyzer::formatMessage(t('You have configured display %display with a path which is an path alias as well. This might lead to unwanted effects so better use an internal path.', array('%display' => $display['display_title'])), 'warning');
}
}
}
return $ret;
}
......@@ -7,6 +7,7 @@
use Drupal\views\ViewExecutable;
use Drupal\views\ViewUI;
use Drupal\views\Analyzer;
use Drupal\Core\Entity\EntityInterface;
/**
......@@ -759,6 +760,37 @@ function views_ui_library_alter(&$libraries, $module) {
}
}
/**
* Implements hook_views_analyze().
*
* This is the basic views analysis that checks for very minimal problems.
* There are other analysis tools in core specific sections, such as
* node.views.inc as well.
*/
function views_ui_views_analyze($view) {
$ret = array();
// Check for something other than the default display:
if (count($view->displayHandlers) < 2) {
$ret[] = Analyzer::formatMessage(t('This view has only a default display and therefore will not be placed anywhere on your site; perhaps you want to add a page or a block display.'), 'warning');
}
// You can give a page display the same path as an alias existing in the
// system, so the alias will not work anymore. Report this to the user,
// because he probably wanted something else.
foreach ($view->displayHandlers as $display) {
if (empty($display)) {
continue;
}
if ($display->hasPath() && $path = $display->getOption('path')) {
$normal_path = drupal_get_normal_path($path);
if ($path != $normal_path) {
$ret[] = Analyzer::formatMessage(t('You have configured display %display with a path which is an path alias as well. This might lead to unwanted effects so better use an internal path.', array('%display' => $display['display_title'])), 'warning');
}
}
}
return $ret;
}
/**
* Truncate strings to a set length and provide a ... if they truncated.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment