Update to Drupal 8.0.5. For more information, see https://www.drupal.org/node/2679347

This commit is contained in:
Pantheon Automation 2016-03-02 12:40:24 -08:00 committed by Greg Anderson
parent 2a9f1f148d
commit fd3b12cf27
251 changed files with 5439 additions and 957 deletions

View file

@ -217,7 +217,7 @@ class EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterfac
$data[$revision_data_table]['table']['group'] = $this->t('@entity_type revision', ['@entity_type' => $this->entityType->getLabel()]);
$data[$revision_data_table]['table']['entity revision'] = TRUE;
$data[$revision_data_table]['table']['join'][$revision_table] = array(
$data[$revision_table]['table']['join'][$revision_data_table] = array(
'left_field' => $revision_field,
'field' => $revision_field,
'type' => 'INNER',

View file

@ -2447,6 +2447,16 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$errors = array_merge($errors, $result);
}
// Check for missing relationships.
$relationships = array_keys($this->getHandlers('relationship'));
foreach (ViewExecutable::getHandlerTypes() as $type => $handler_type_info) {
foreach ($this->getHandlers($type) as $handler_id => $handler) {
if (!empty($handler->options['relationship']) && $handler->options['relationship'] != 'none' && !in_array($handler->options['relationship'], $relationships)) {
$errors[] = $this->t('The %handler_type %handler uses a relationship that has been removed.', array('%handler_type' => $handler_type_info['lstitle'], '%handler' => $handler->adminLabel()));
}
}
}
// Validate handlers.
foreach (ViewExecutable::getHandlerTypes() as $type => $info) {
foreach ($this->getHandlers($type) as $handler) {

View file

@ -39,7 +39,7 @@ interface DisplayRouterInterface extends DisplayPluginInterface {
public function alterRoutes(RouteCollection $collection);
/**
* Generates an URL to this display.
* Generates a URL to this display.
*
* @return \Drupal\Core\Url
* A URL object for the display.

View file

@ -1363,6 +1363,43 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
];
$path = $alter['path'];
// strip_tags() and viewsTokenReplace remove <front>, so check whether it's
// different to front.
if ($path != '<front>') {
// Use strip_tags as there should never be HTML in the path.
// However, we need to preserve special characters like " that were
// removed by SafeMarkup::checkPlain().
$path = Html::decodeEntities($this->viewsTokenReplace($alter['path'], $tokens));
// Tokens might contain <front>, so check for <front> again.
if ($path != '<front>') {
$path = strip_tags($path);
}
// Tokens might have resolved URL's, as is the case for tokens provided by
// Link fields, so all internal paths will be prefixed by base_path(). For
// proper further handling reset this to internal:/.
if (strpos($path, base_path()) === 0) {
$path = 'internal:/' . substr($path, strlen(base_path()));
}
// If we have no $path and no $alter['url'], we have nothing to work with,
// so we just return the text.
if (empty($path) && empty($alter['url'])) {
return $text;
}
// If no scheme is provided in the $path, assign the default 'http://'.
// This allows a url of 'www.example.com' to be converted to
// 'http://www.example.com'.
// Only do this when flag for external has been set, $path doesn't contain
// a scheme and $path doesn't have a leading /.
if ($alter['external'] && !parse_url($path, PHP_URL_SCHEME) && strpos($path, '/') !== 0) {
// There is no scheme, add the default 'http://' to the $path.
$path = "http://" . $path;
}
}
if (empty($alter['url'])) {
if (!parse_url($path, PHP_URL_SCHEME)) {
// @todo Views should expect and store a leading /. See
@ -1378,28 +1415,12 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
$path = $alter['url']->setOptions($options)->toUriString();
// strip_tags() removes <front>, so check whether its different to front.
if ($path != 'route:<front>') {
// Unescape Twig delimiters that may have been escaped by the
// Url::toUriString() call above, because we support twig tokens in
// rewrite settings of views fields.
// In that case the original path looks like
// internal:/admin/content/files/usage/{{ fid }}, which will be escaped by
// the toUriString() call above.
$path = preg_replace(['/(\%7B){2}(\%20)*/', '/(\%20)*(\%7D){2}/'], ['{{', '}}'], $path);
if (!empty($alter['path_case']) && $alter['path_case'] != 'none' && !$alter['url']->isRouted()) {
$path = str_replace($alter['path'], $this->caseTransform($alter['path'], $this->options['alter']['path_case']), $path);
}
// Use strip tags as there should never be HTML in the path.
// However, we need to preserve special characters like " that are escaped
// by \Drupal\Component\Utility\Html::escape().
$path = strip_tags(Html::decodeEntities($this->viewsTokenReplace($path, $tokens)));
if (!empty($alter['path_case']) && $alter['path_case'] != 'none' && !$alter['url']->isRouted()) {
$path = str_replace($alter['path'], $this->caseTransform($alter['path'], $this->options['alter']['path_case']), $path);
}
if (!empty($alter['replace_spaces'])) {
$path = str_replace(' ', '-', $path);
}
if (!empty($alter['replace_spaces'])) {
$path = str_replace(' ', '-', $path);
}
// Parse the URL and move any query and fragment parameters out of the path.
@ -1421,19 +1442,6 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
// $path now so we don't get query strings or fragments in the path.
$path = $url['path'];
// If no scheme is provided in the $path, assign the default 'http://'.
// This allows a url of 'www.example.com' to be converted to 'http://www.example.com'.
// Only do this on for external URLs.
if ($alter['external']) {
if (!isset($url['scheme'])) {
// There is no scheme, add the default 'http://' to the $path.
// Use the original $alter['path'] instead of the parsed version.
$path = "http://" . $alter['path'];
// Reset the $url array to include the new scheme.
$url = UrlHelper::parse($path);
}
}
if (isset($url['query'])) {
// Remove query parameters that were assigned a query string replacement
// token for which there is no value available.

View file

@ -1039,7 +1039,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
$display_options['pager']['type'] = 'none';
}
// If the user checked the pager checkbox use a full pager.
elseif (isset($page['pager'])) {
elseif (!empty($page['pager'])) {
$display_options['pager']['type'] = 'full';
}
// If the user doesn't have checked the checkbox use the pager which just

View file

@ -275,20 +275,28 @@ class ModuleTest extends ViewKernelTestBase {
public function testViewsEmbedView() {
$this->enableModules(array('user'));
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$result = views_embed_view('test_argument');
$this->assertEqual(count($result['#view']->result), 5);
$renderer->renderPlain($result);
$this->assertEqual(count($result['view_build']['#view']->result), 5);
$result = views_embed_view('test_argument', 'default', 1);
$this->assertEqual(count($result['#view']->result), 1);
$renderer->renderPlain($result);
$this->assertEqual(count($result['view_build']['#view']->result), 1);
$result = views_embed_view('test_argument', 'default', '1,2');
$this->assertEqual(count($result['#view']->result), 2);
$renderer->renderPlain($result);
$this->assertEqual(count($result['view_build']['#view']->result), 2);
$result = views_embed_view('test_argument', 'default', '1,2', 'John');
$this->assertEqual(count($result['#view']->result), 1);
$renderer->renderPlain($result);
$this->assertEqual(count($result['view_build']['#view']->result), 1);
$result = views_embed_view('test_argument', 'default', '1,2', 'John,George');
$this->assertEqual(count($result['#view']->result), 2);
$renderer->renderPlain($result);
$this->assertEqual(count($result['view_build']['#view']->result), 2);
}
/**

View file

@ -7,6 +7,8 @@
namespace Drupal\views\Tests\Plugin;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\views\Views;
use Drupal\views_test_data\Plugin\views\argument_default\ArgumentDefaultTest as ArgumentDefaultTestPlugin;
@ -23,14 +25,19 @@ class ArgumentDefaultTest extends PluginTestBase {
*
* @var array
*/
public static $testViews = array('test_view', 'test_argument_default_fixed', 'test_argument_default_current_user');
public static $testViews = array(
'test_view',
'test_argument_default_fixed',
'test_argument_default_current_user',
'test_argument_default_node',
);
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node', 'views_ui');
public static $modules = array('node', 'views_ui', 'block');
protected function setUp() {
parent::setUp();
@ -80,7 +87,7 @@ class ArgumentDefaultTest extends PluginTestBase {
/**
* Tests the use of a default argument plugin that provides no options.
*/
function testArgumentDefaultNoOptions() {
public function testArgumentDefaultNoOptions() {
$admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
$this->drupalLogin($admin_user);
@ -104,7 +111,7 @@ class ArgumentDefaultTest extends PluginTestBase {
/**
* Tests fixed default argument.
*/
function testArgumentDefaultFixed() {
public function testArgumentDefaultFixed() {
$random = $this->randomMachineName();
$view = Views::getView('test_argument_default_fixed');
$view->setDisplay();
@ -128,8 +135,37 @@ class ArgumentDefaultTest extends PluginTestBase {
//function testArgumentDefaultPhp() {}
/**
* @todo Test node default argument.
* Test node default argument.
*/
//function testArgumentDefaultNode() {}
public function testArgumentDefaultNode() {
// Create a user that has permission to place a view block.
$permissions = array(
'administer views',
'administer blocks',
'bypass node access',
'access user profiles',
'view all revisions',
);
$views_admin = $this->drupalCreateUser($permissions);
$this->drupalLogin($views_admin);
// Create nodes where should show themselves again as view block.
$node_type = NodeType::create(['type' => 'page', 'label' => 'Page']);
$node_type->save();
$node1 = Node::create(['title' => 'Test node 1', 'type' => 'page']);
$node1->save();
$node2 = Node::create(['title' => 'Test node 2', 'type' => 'page']);
$node2->save();
// Place the block, visit the pages that display the block, and check that
// the nodes we expect appear in the respective pages.
$id = 'view-block-id';
$this->drupalPlaceBlock("views_block:test_argument_default_node-block_1", ['id' => $id]);
$xpath = '//*[@id="block-' . $id . '"]';
$this->drupalGet('node/' . $node1->id());
$this->assertTrue(strpos($this->xpath($xpath)[0]->asXml(), $node1->getTitle()));
$this->drupalGet('node/' . $node2->id());
$this->assertTrue(strpos($this->xpath($xpath)[0]->asXml(), $node2->getTitle()));
}
}

View file

@ -23,7 +23,7 @@ class DisplayTest extends PluginTestBase {
*
* @var array
*/
public static $testViews = array('test_filter_groups', 'test_get_attach_displays', 'test_view', 'test_display_more', 'test_display_invalid', 'test_display_empty');
public static $testViews = array('test_filter_groups', 'test_get_attach_displays', 'test_view', 'test_display_more', 'test_display_invalid', 'test_display_empty', 'test_exposed_relationship_admin_ui');
/**
* Modules to enable.
@ -290,7 +290,7 @@ class DisplayTest extends PluginTestBase {
$config->save();
// Place the block display.
$block = $this->drupalPlaceBlock('views_block:test_display_invalid-block_1', array(), array('title' => 'Invalid display'));
$block = $this->drupalPlaceBlock('views_block:test_display_invalid-block_1', array('label' => 'Invalid display'));
$this->drupalGet('<front>');
$this->assertResponse(200);
@ -309,6 +309,31 @@ class DisplayTest extends PluginTestBase {
$this->assertNoBlockAppears($block);
}
/**
* Tests display validation when a required relationship is missing.
*/
public function testMissingRelationship() {
$view = Views::getView('test_exposed_relationship_admin_ui');
// Remove the relationship that is not used by other handlers.
$view->removeHandler('default', 'relationship', 'uid_1');
$errors = $view->validate();
// Check that no error message is shown.
$this->assertTrue(empty($errors['default']), 'No errors found when removing unused relationship.');
// Unset cached relationships (see DisplayPluginBase::getHandlers())
unset($view->display_handler->handlers['relationship']);
// Remove the relationship used by other handlers.
$view->removeHandler('default', 'relationship', 'uid');
// Validate display
$errors = $view->validate();
// Check that the error messages are shown.
$this->assertTrue(count($errors['default']) == 2, 'Error messages found for required relationship');
$this->assertEqual($errors['default'][0], t('The %handler_type %handler uses a relationship that has been removed.', array('%handler_type' => 'field', '%handler' => 'User: Last login')));
$this->assertEqual($errors['default'][1], t('The %handler_type %handler uses a relationship that has been removed.', array('%handler_type' => 'field', '%handler' => 'User: Created')));
}
/**
* Tests the outputIsEmpty method on the display.
*/

View file

@ -0,0 +1,66 @@
<?php
/**
* @file
* Contains \Drupal\views\Tests\Wizard\PagerTest.
*/
namespace Drupal\views\Tests\Wizard;
/**
* Tests the ability of the views wizard to create views without a pager.
*
* @group views
*/
class PagerTest extends WizardTestBase {
/**
* Tests the pager option.
*/
public function testPager() {
// Create nodes, each with a different creation time so that we have
// conditions that are meaningful for the use of a pager.
$this->drupalCreateContentType(array('type' => 'page'));
for ($i = 0; $i < 12; $i++) {
$this->drupalCreateNode(array('created' => REQUEST_TIME - $i));
}
// Make a View that uses a pager.
$path_with_pager = 'test-view-with-pager';
$this->createViewAtPath($path_with_pager, TRUE);
$this->drupalGet($path_with_pager);
// This technique for finding the existence of a pager
// matches that used in Drupal\views_ui\Tests\PreviewTest.php.
$elements = $this->xpath('//ul[contains(@class, :class)]/li', array(':class' => 'pager__items'));
$this->assertTrue(!empty($elements), 'Full pager found.');
// Make a View that does not have a pager.
$path_with_no_pager = 'test-view-without-pager';
$this->createViewAtPath($path_with_no_pager, FALSE);
$this->drupalGet($path_with_no_pager);
$elements = $this->xpath('//ul[contains(@class, :class)]/li', array(':class' => 'pager__items'));
$this->assertTrue(empty($elements), 'Full pager not found.');
}
/**
* Create a simple View of nodes at a given path.
*
* @param string $path
* The path at which the View should be created.
* @param bool $pager
* A boolean for whether the View created should use a pager.
*/
protected function createViewAtPath($path, $pager = TRUE) {
$view = array();
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['show[sort]'] = 'node_field_data-created:ASC';
$view['page[create]'] = 1;
$view['page[title]'] = $this->randomMachineName(16);
$view['page[path]'] = $path;
$view['page[pager]'] = $pager;
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
}
}

View file

@ -41,14 +41,14 @@ class TaggedWithTest extends WizardTestBase {
protected $nodeTypeWithoutTags;
/**
* Node type without an autocomplete tagging field.
* The vocabulary used for the test tag field.
*
* @var \Drupal\taxonomy\VocabularyInterface
*/
protected $tagVocabulary;
/**
* Node type without an autocomplete tagging field.
* Holds the field storage for test tag field.
*
* @var \Drupal\field\FieldStorageConfigInterface
*/

View file

@ -8,12 +8,12 @@
namespace Drupal\views;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Tags;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Form\FormState;
use Drupal\Core\Routing\RouteProviderInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\views\Plugin\views\display\DisplayRouterInterface;
use Drupal\Component\Utility\Tags;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
@ -473,8 +473,10 @@ class ViewExecutable implements \Serializable {
}
/**
* Set the arguments that come to this view. Usually from the URL
* but possibly from elsewhere.
* Sets the arguments for the view.
*
* @param array $args
* The arguments passed to the view.
*/
public function setArguments(array $args) {
// The array keys of the arguments will be incorrect if set by
@ -497,7 +499,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Change/Set the current page for the pager.
* Sets the current page for the pager.
*
* @param int $page
* The current page.
@ -519,7 +521,10 @@ class ViewExecutable implements \Serializable {
}
/**
* Get the current page from the pager.
* Gets the current page from the pager.
*
* @return int
* The current page.
*/
public function getCurrentPage() {
// If the pager is already initialized, pass it through to the pager.
@ -533,7 +538,10 @@ class ViewExecutable implements \Serializable {
}
/**
* Get the items per page from the pager.
* Gets the items per page from the pager.
*
* @return int
* The items per page.
*/
public function getItemsPerPage() {
// If the pager is already initialized, pass it through to the pager.
@ -547,7 +555,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Set the items per page on the pager.
* Sets the items per page on the pager.
*
* @param int $items_per_page
* The items per page.
@ -567,7 +575,10 @@ class ViewExecutable implements \Serializable {
}
/**
* Get the pager offset from the pager.
* Gets the pager offset from the pager.
*
* @return int
* The pager offset.
*/
public function getOffset() {
// If the pager is already initialized, pass it through to the pager.
@ -581,7 +592,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Set the offset on the pager.
* Sets the offset on the pager.
*
* @param int $offset
* The pager offset.
@ -603,7 +614,10 @@ class ViewExecutable implements \Serializable {
}
/**
* Determine if the pager actually uses a pager.
* Determines if the view uses a pager.
*
* @return bool
* TRUE if the view uses a pager, FALSE otherwise.
*/
public function usePager() {
if (!empty($this->pager)) {
@ -625,26 +639,36 @@ class ViewExecutable implements \Serializable {
}
/**
* Whether or not AJAX should be used.
*
* @see \Drupal\views\ViewExecutable::setAjaxEnabled().
* Determines whether or not AJAX should be used.
*
* @return bool
* TRUE if AJAX is enabled, FALSE otherwise.
*/
public function ajaxEnabled() {
return $this->ajaxEnabled;
}
/**
* Set the exposed filters input to an array. If unset they will be taken
* from \Drupal::request()->query when the time comes.
* Sets the exposed filters input to an array.
*
* @param string[] $filters
* The values taken from the view's exposed filters and sorts.
*/
public function setExposedInput($filters) {
$this->exposed_input = $filters;
}
/**
* Figure out what the exposed input for this view is.
* Figures out what the exposed input for this view is.
*
* They will be taken from \Drupal::request()->query or from
* something previously set on the view.
*
* @return string[]
* An array containing the exposed input values keyed by the filter and sort
* name.
*
* @see self::setExposedInput()
*/
public function getExposedInput() {
// Fill our input either from \Drupal::request()->query or from something
@ -678,7 +702,10 @@ class ViewExecutable implements \Serializable {
}
/**
* Set the display for this view and initialize the display handler.
* Sets the display for this view and initializes the display handler.
*
* @return true
* Always returns TRUE.
*/
public function initDisplay() {
if (isset($this->current_display)) {
@ -695,7 +722,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Get the first display that is accessible to the user.
* Gets the first display that is accessible to the user.
*
* @param array|string $displays
* Either a single display id or an array of display ids.
@ -723,6 +750,7 @@ class ViewExecutable implements \Serializable {
* Gets the current display plugin.
*
* @return \Drupal\views\Plugin\views\display\DisplayPluginBase
* The current display plugin.
*/
public function getDisplay() {
if (!isset($this->display_handler)) {
@ -815,6 +843,7 @@ class ViewExecutable implements \Serializable {
* Gets the current style plugin.
*
* @return \Drupal\views\Plugin\views\style\StylePluginBase
* The current style plugin.
*/
public function getStyle() {
if (!isset($this->style_plugin)) {
@ -825,10 +854,13 @@ class ViewExecutable implements \Serializable {
}
/**
* Find and initialize the style plugin.
* Finds and initializes the style plugin.
*
* Note that arguments may have changed which style plugin we use, so
* check the view object first, then ask the display handler.
*
* @return bool
* TRUE if the style plugin was or could be initialized, FALSE otherwise.
*/
public function initStyle() {
if (isset($this->style_plugin)) {
@ -845,7 +877,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Acquire and attach all of the handlers.
* Acquires and attaches all of the handlers.
*/
public function initHandlers() {
$this->initDisplay();
@ -858,9 +890,10 @@ class ViewExecutable implements \Serializable {
}
/**
* Get the current pager plugin.
* Gets the current pager plugin.
*
* @return \Drupal\views\Plugin\views\pager\PagerPluginBase
* The current pager plugin.
*/
public function getPager() {
if (!isset($this->pager)) {
@ -871,10 +904,10 @@ class ViewExecutable implements \Serializable {
}
/**
* Initialize the pager
* Initializes the pager.
*
* Like style initialization, pager initialization is held until late
* to allow for overrides.
* Like style initialization, pager initialization is held until late to allow
* for overrides.
*/
public function initPager() {
if (!isset($this->pager)) {
@ -897,7 +930,13 @@ class ViewExecutable implements \Serializable {
}
/**
* Render the pager, if necessary.
* Renders the pager, if necessary.
*
* @param string[] $exposed_input
* The input values from the exposed forms and sorts of the view.
*
* @return array|string
* The render array of the pager if it's set, blank string otherwise.
*/
public function renderPager($exposed_input) {
if (!empty($this->pager) && $this->pager->usePager()) {
@ -908,8 +947,12 @@ class ViewExecutable implements \Serializable {
}
/**
* Create a list of base tables eligible for this view. Used primarily
* for the UI. Display must be already initialized.
* Creates a list of base tables to be used by the view.
*
* This is used primarily for the UI. The display must be already initialized.
*
* @return array
* An array of base tables to be used by the view.
*/
public function getBaseTables() {
$base_tables = array(
@ -924,7 +967,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Run the preQuery() on all active handlers.
* Runs the preQuery() on all active handlers.
*/
protected function _preQuery() {
foreach ($this::getHandlerTypes() as $key => $info) {
@ -939,7 +982,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Run the postExecute() on all active handlers.
* Runs the postExecute() on all active handlers.
*/
protected function _postExecute() {
foreach ($this::getHandlerTypes() as $key => $info) {
@ -951,12 +994,13 @@ class ViewExecutable implements \Serializable {
}
/**
* Attach all of the handlers for each type.
* Attaches the views handler for the specific type.
*
* @param $key
* One of 'argument', 'field', 'sort', 'filter', 'relationship'
* @param $info
* The $info from getHandlerTypes for this object.
* @param string $key
* One of 'argument', 'field', 'sort', 'filter', 'relationship'.
* @param array $info
* An array of views handler types use in the view with additional
* information about them.
*/
protected function _initHandler($key, $info) {
// Load the requested items from the display onto the object.
@ -974,7 +1018,10 @@ class ViewExecutable implements \Serializable {
}
/**
* Build all the arguments.
* Builds all the arguments.
*
* @return bool
* TRUE if the arguments were built successfully, FALSE otherwise.
*/
protected function _buildArguments() {
// Initially, we want to build sorts and fields. This can change, though,
@ -1064,6 +1111,7 @@ class ViewExecutable implements \Serializable {
* Gets the current query plugin.
*
* @return \Drupal\views\Plugin\views\query\QueryPluginBase
* The current query plugin.
*/
public function getQuery() {
if (!isset($this->query)) {
@ -1074,7 +1122,10 @@ class ViewExecutable implements \Serializable {
}
/**
* Do some common building initialization.
* Initializes the query object for the view.
*
* @return true
* Always returns TRUE.
*/
public function initQuery() {
if (!empty($this->query)) {
@ -1097,7 +1148,14 @@ class ViewExecutable implements \Serializable {
}
/**
* Build the query for the view.
* Builds the query for the view.
*
* @param string $display_id
* The display ID of the view.
*
* @return bool|null
* TRUE if the view build process was successful, FALSE if setting the
* display fails or NULL if the view has been built already.
*/
public function build($display_id = NULL) {
if (!empty($this->built)) {
@ -1239,7 +1297,9 @@ class ViewExecutable implements \Serializable {
}
/**
* Internal method to build an individual set of handlers.
* Builds an individual set of handlers.
*
* This is an internal method.
*
* @todo Some filter needs this function, even it is internal.
*
@ -1280,14 +1340,14 @@ class ViewExecutable implements \Serializable {
}
/**
* Execute the view's query.
* Executes the view's query.
*
* @param string $display_id
* The machine name of the display, which should be executed.
*
* @return bool
* Return whether the executing was successful, for example an argument
* could stop the process.
* TRUE if the view execution was successful, FALSE otherwise. For example,
* an argument could stop the process.
*/
public function execute($display_id = NULL) {
if (empty($this->built)) {
@ -1311,8 +1371,9 @@ class ViewExecutable implements \Serializable {
$module_handler->invokeAll('views_pre_execute', array($this));
// Check for already-cached results.
/** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache */
if (!empty($this->live_preview)) {
$cache = $this->display_handler->getPlugin('cache', 'none');
$cache = Views::pluginManager('cache')->createInstance('none');
}
else {
$cache = $this->display_handler->getPlugin('cache');
@ -1340,7 +1401,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Render this view for a certain display.
* Renders this view for a certain display.
*
* Note: You should better use just the preview function if you want to
* render a view.
@ -1348,8 +1409,9 @@ class ViewExecutable implements \Serializable {
* @param string $display_id
* The machine name of the display, which should be rendered.
*
* @return string|null
* Return the output of the rendered view or NULL if something failed in the process.
* @return array|null
* A renderable array containing the view output or NULL if the build
* process failed.
*/
public function render($display_id = NULL) {
$this->execute($display_id);
@ -1496,7 +1558,8 @@ class ViewExecutable implements \Serializable {
}
/**
* Execute the given display, with the given arguments.
* Executes the given display, with the given arguments.
*
* To be called externally by whatever mechanism invokes the view,
* such as a page callback, hook_block, etc.
*
@ -1506,6 +1569,15 @@ class ViewExecutable implements \Serializable {
* use of the display, such as setting page titles.
*
* If you simply want to view the display, use View::preview() instead.
*
* @param string $display_id
* The display ID of the view to be executed.
* @param string[] $args
* The arguments to be passed to the view.
*
* @return array|null
* A renderable array containing the view output or NULL if the display ID
* of the view to be executed doesn't exist.
*/
public function executeDisplay($display_id = NULL, $args = array()) {
if (empty($this->current_display) || $this->current_display != $this->chooseDisplay($display_id)) {
@ -1524,7 +1596,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Preview the given display, with the given arguments.
* Previews the given display, with the given arguments.
*
* To be called externally, probably by an AJAX handler of some flavor.
* Can also be called when views are embedded, as this guarantees
@ -1534,6 +1606,10 @@ class ViewExecutable implements \Serializable {
* responsibility of the caller to check $view->access() or implement other
* access logic. To render the view normally with access checks, use
* views_embed_view() instead.
*
* @return array|null
* A renderable array containing the view output or NULL if the display ID
* of the view to be executed doesn't exist.
*/
public function preview($display_id = NULL, $args = array()) {
if (empty($this->current_display) || ((!empty($display_id)) && $this->current_display != $display_id)) {
@ -1552,8 +1628,10 @@ class ViewExecutable implements \Serializable {
}
/**
* Run attachments and let the display do what it needs to do prior
* to running.
* Runs attachments and lets the display do what it needs to before running.
*
* @param array @args
* An array of arguments from the URL that can be used by the view.
*/
public function preExecute($args = array()) {
$this->old_view[] = views_get_current_view();
@ -1577,7 +1655,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Unset the current view, mostly.
* Unsets the current view, mostly.
*/
public function postExecute() {
// unset current view so we can be properly destructed later on.
@ -1591,7 +1669,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Run attachment displays for the view.
* Runs attachment displays for the view.
*/
public function attachDisplays() {
if (!empty($this->is_attachment)) {
@ -1616,8 +1694,17 @@ class ViewExecutable implements \Serializable {
}
/**
* Determine if the given user has access to the view. Note that
* this sets the display handler if it hasn't been.
* Determines if the given user has access to the view.
*
* Note that this sets the display handler if it hasn't been set.
*
* @param string $displays
* The machine name of the display.
* @param \Drupal\Core\Session\AccountInterface $account
* The user object.
*
* @return bool
* TRUE if the user has access to the view, FALSE otherwise.
*/
public function access($displays = NULL, $account = NULL) {
// No one should have access to disabled views.
@ -1683,16 +1770,20 @@ class ViewExecutable implements \Serializable {
/**
* Gets the request object.
*
* @return \Symfony\Component\HttpFoundation\Request $request
* Returns the request object.
* @return \Symfony\Component\HttpFoundation\Request
* The request object.
*/
public function getRequest() {
return $this->request;
}
/**
* Get the view's current title. This can change depending upon how it
* was built.
* Gets the view's current title.
*
* This can change depending upon how it was built.
*
* @return string|false
* The view title, FALSE if the display is not set.
*/
public function getTitle() {
if (empty($this->display_handler)) {
@ -1717,9 +1808,12 @@ class ViewExecutable implements \Serializable {
}
/**
* Override the view's current title.
* Overrides the view's current title.
*
* The tokens in the title get's replaced before rendering.
*
* @return true
* Always returns TRUE.
*/
public function setTitle($title) {
$this->build_info['title'] = $title;
@ -1727,7 +1821,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Force the view to build a title.
* Forces the view to build a title.
*/
public function buildTitle() {
$this->initDisplay();
@ -1753,6 +1847,7 @@ class ViewExecutable implements \Serializable {
* (optional) The display ID. The current display will be used by default.
*
* @return bool
* TRUE if the current display has a valid route available, FALSE otherwise.
*/
public function hasUrl($args = NULL, $display_id = NULL) {
if (!empty($this->override_url)) {
@ -1781,7 +1876,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Get the URL for the current view.
* Gets the URL for the current view.
*
* This URL will be adjusted for arguments.
*
@ -1791,6 +1886,10 @@ class ViewExecutable implements \Serializable {
* (optional) Specify the display ID to link to, fallback to the current ID.
*
* @return \Drupal\Core\Url
* The URL of the current view.
*
* @throws \InvalidArgumentException
* Thrown when the current view doesn't have a route available.
*/
public function getUrl($args = NULL, $display_id = NULL) {
if (!empty($this->override_url)) {
@ -1863,7 +1962,7 @@ class ViewExecutable implements \Serializable {
* Gets the Url object associated with the display handler.
*
* @param string $display_id
* (Optional) The display id. ( Used only to detail an exception. )
* (optional) The display ID (used only to detail an exception).
*
* @return \Drupal\Core\Url
* The display handlers URL object.
@ -1880,7 +1979,10 @@ class ViewExecutable implements \Serializable {
}
/**
* Get the base path used for this view.
* Gets the base path used for this view.
*
* @return string|false
* The base path used for the view or FALSE if setting the display fails.
*/
public function getPath() {
if (!empty($this->override_path)) {
@ -1902,6 +2004,7 @@ class ViewExecutable implements \Serializable {
* injection.
*
* @return \Drupal\Core\Session\AccountInterface
* The current user.
*/
public function getUser() {
return $this->user;
@ -1918,8 +2021,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Unset references so that a $view object may be properly garbage
* collected.
* Unsets references so that a $view object may be properly garbage collected.
*/
public function destroy() {
foreach ($this::getHandlerTypes() as $type => $info) {
@ -1977,8 +2079,9 @@ class ViewExecutable implements \Serializable {
}
/**
* Provide a list of views handler types used in a view, with some information
* about them.
* Provides a list of views handler types used in a view.
*
* This also provides some information about the views handler types.
*
* @return array
* An array of associative arrays containing:
@ -2243,7 +2346,7 @@ class ViewExecutable implements \Serializable {
* Returns whether admin links should be rendered on the view.
*
* @return bool
* Returns TRUE if admin links should be rendered, else FALSE.
* TRUE if admin links should be rendered, else FALSE.
*/
public function getShowAdminLinks() {
if (!isset($this->showAdminLinks)) {
@ -2264,7 +2367,7 @@ class ViewExecutable implements \Serializable {
}
/**
* Provide a full array of possible theme functions to try for a given hook.
* Provides a full array of possible theme functions to try for a given hook.
*
* @param string $hook
* The hook to use. This is the base theme/template name.
@ -2300,8 +2403,8 @@ class ViewExecutable implements \Serializable {
* Determines if this view has form elements.
*
* @return bool
* Returns TRUE if this view contains handlers with views form
* implementations, FALSE otherwise.
* TRUE if this view contains handlers with views form implementations,
* FALSE otherwise.
*/
public function hasFormElements() {
foreach ($this->field as $field) {

View file

@ -114,8 +114,17 @@ class ViewsDataHelper {
elseif (!empty($table_data['table'][$string])) {
$strings[$field][$key][$string] = $table_data['table'][$string];
}
// We don't have any help provided for this field. If a better
// description should be used for the Views UI you use
// hook_views_data_alter() in module.views.inc or implement a
// custom entity views_data handler.
// @see hook_views_data_alter()
// @see \Drupal\node\NodeViewsData
elseif ($string == 'help') {
$strings[$field][$key][$string] = '';
}
else {
if ($string != 'base' && $string != 'base') {
if ($string != 'base') {
$strings[$field][$key][$string] = SafeMarkup::format("Error: missing @component", array('@component' => $string));
}
}