Update to Drupal 8.1.2. For more information, see https://www.drupal.org/project/drupal/releases/8.1.2
This commit is contained in:
parent
9eae24d844
commit
28556d630e
1322 changed files with 6699 additions and 2064 deletions
|
@ -105,5 +105,4 @@ class DisplayPluginCollection extends DefaultLazyPluginCollection {
|
|||
parent::remove($instance_id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -88,7 +88,6 @@ class EntityFieldRenderer extends RendererBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
protected function getLanguageManager() {
|
||||
return $this->languageManager;
|
||||
}
|
||||
|
|
|
@ -74,4 +74,5 @@ class TranslationLanguageRenderer extends EntityTranslationRendererBase {
|
|||
public function getCacheContexts() {
|
||||
return ['languages:' . LanguageInterface::TYPE_CONTENT];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ use Drupal\views\Plugin\views\HandlerBase;
|
|||
* definition terms:
|
||||
* - numeric: If true, treat this field as numeric, using %d instead of %s in
|
||||
* queries.
|
||||
*
|
||||
*/
|
||||
class ManyToOneHelper {
|
||||
|
||||
|
|
|
@ -31,4 +31,5 @@ class DefaultWizardDeriver extends DeriverBase {
|
|||
}
|
||||
return parent::getDerivativeDefinitions($base_plugin_definition);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -132,4 +132,5 @@ class ViewsHandlerManager extends DefaultPluginManager implements FallbackPlugin
|
|||
public function getFallbackPluginId($plugin_id, array $configuration = array()) {
|
||||
return 'broken';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ trait BrokenHandlerTrait {
|
|||
/**
|
||||
* Returns this handlers name in the UI.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\PluginBase::defineOptions().
|
||||
* @see \Drupal\views\Plugin\views\PluginBase::defineOptions()
|
||||
*/
|
||||
public function adminLabel($short = FALSE) {
|
||||
return t('Broken/missing handler');
|
||||
|
@ -22,7 +22,7 @@ trait BrokenHandlerTrait {
|
|||
/**
|
||||
* The option definition for this handler.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\PluginBase::defineOptions().
|
||||
* @see \Drupal\views\Plugin\views\PluginBase::defineOptions()
|
||||
*/
|
||||
public function defineOptions() {
|
||||
return array();
|
||||
|
@ -32,7 +32,7 @@ trait BrokenHandlerTrait {
|
|||
* Ensure the main table for this handler is in the query. This is used
|
||||
* a lot.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\HandlerBase::ensureMyTable().
|
||||
* @see \Drupal\views\Plugin\views\HandlerBase::ensureMyTable()
|
||||
*/
|
||||
public function ensureMyTable() {
|
||||
// No table to ensure.
|
||||
|
@ -48,7 +48,7 @@ trait BrokenHandlerTrait {
|
|||
/**
|
||||
* Provides a form to edit options for this plugin.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\PluginBase::defineOptions().
|
||||
* @see \Drupal\views\Plugin\views\PluginBase::defineOptions()
|
||||
*/
|
||||
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
|
||||
$description_top = t('The handler for this item is broken or missing. The following details are available:');
|
||||
|
@ -84,7 +84,7 @@ trait BrokenHandlerTrait {
|
|||
*
|
||||
* This means it's a placeholder used when a handler can't be found.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\HandlerBase::broken().
|
||||
* @see \Drupal\views\Plugin\views\HandlerBase::broken()
|
||||
*/
|
||||
public function broken() {
|
||||
return TRUE;
|
||||
|
@ -95,7 +95,7 @@ trait BrokenHandlerTrait {
|
|||
*
|
||||
* @return array
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\PluginBase::calculateDependencies().
|
||||
* @see \Drupal\views\Plugin\views\PluginBase::calculateDependencies()
|
||||
*/
|
||||
public function calculateDependencies() {
|
||||
return [];
|
||||
|
|
|
@ -815,4 +815,5 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
|
|||
// Write to cache
|
||||
$view->cacheSet();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -196,7 +196,6 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
|
|||
*
|
||||
* @param array $storage
|
||||
* The stored options.
|
||||
*
|
||||
* @param array $options
|
||||
* The defined options.
|
||||
*/
|
||||
|
@ -373,7 +372,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
|
|||
$top = array_shift($parts);
|
||||
assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $top) === 1', 'Tokens need to be valid Twig variables.');
|
||||
$token_array = array(array_pop($parts) => $replacement);
|
||||
foreach(array_reverse($parts) as $key) {
|
||||
foreach (array_reverse($parts) as $key) {
|
||||
assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $key) === 1', 'Tokens need to be valid Twig variables.');
|
||||
$token_array = array($key => $token_array);
|
||||
}
|
||||
|
|
|
@ -194,4 +194,5 @@ class Entity extends TokenizeAreaPluginBase {
|
|||
|
||||
return $dependencies;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,15 +55,15 @@ use Drupal\views\Views;
|
|||
*/
|
||||
abstract class ArgumentPluginBase extends HandlerBase implements CacheableDependencyInterface {
|
||||
|
||||
var $validator = NULL;
|
||||
var $argument = NULL;
|
||||
var $value = NULL;
|
||||
public $validator = NULL;
|
||||
public $argument = NULL;
|
||||
public $value = NULL;
|
||||
|
||||
/**
|
||||
* The table to use for the name, should it not be in the same table as the argument.
|
||||
* @var string
|
||||
*/
|
||||
var $name_table;
|
||||
public $name_table;
|
||||
|
||||
/**
|
||||
* The field to use for the name to use in the summary, which is
|
||||
|
@ -71,7 +71,7 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
|
|||
* the argument itself is the nid, but node.title is displayed.
|
||||
* @var string
|
||||
*/
|
||||
var $name_field;
|
||||
public $name_field;
|
||||
|
||||
/**
|
||||
* Overrides Drupal\views\Plugin\views\HandlerBase:init().
|
||||
|
@ -1206,7 +1206,7 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
|
|||
* @return string
|
||||
* The sanitized identifier.
|
||||
*
|
||||
* @see decodeValidatorId().
|
||||
* @see decodeValidatorId()
|
||||
*/
|
||||
public static function encodeValidatorId($id) {
|
||||
return str_replace(':', '---', $id);
|
||||
|
|
|
@ -40,7 +40,7 @@ class Date extends Formula implements ContainerFactoryPluginInterface {
|
|||
*/
|
||||
protected $argFormat = 'Y-m-d';
|
||||
|
||||
var $option_name = 'default_argument_date';
|
||||
public $option_name = 'default_argument_date';
|
||||
|
||||
/**
|
||||
* The route match.
|
||||
|
|
|
@ -19,7 +19,7 @@ use Drupal\views\ViewExecutable;
|
|||
*/
|
||||
class Formula extends ArgumentPluginBase {
|
||||
|
||||
var $formula = NULL;
|
||||
public $formula = NULL;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -58,7 +58,7 @@ class Formula extends ArgumentPluginBase {
|
|||
$this->ensureMyTable();
|
||||
// Now that our table is secure, get our formula.
|
||||
$placeholder = $this->placeholder();
|
||||
$formula = $this->getFormula() .' = ' . $placeholder;
|
||||
$formula = $this->getFormula() . ' = ' . $placeholder;
|
||||
$placeholders = array(
|
||||
$placeholder => $this->argument,
|
||||
);
|
||||
|
|
|
@ -18,13 +18,13 @@ class NumericArgument extends ArgumentPluginBase {
|
|||
* The operator used for the query: or|and.
|
||||
* @var string
|
||||
*/
|
||||
var $operator;
|
||||
public $operator;
|
||||
|
||||
/**
|
||||
* The actual value which is used for querying.
|
||||
* @var array
|
||||
*/
|
||||
var $value;
|
||||
public $value;
|
||||
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
|
|
|
@ -31,7 +31,7 @@ abstract class CachePluginBase extends PluginBase {
|
|||
/**
|
||||
* Contains all data that should be written/read from cache.
|
||||
*/
|
||||
var $storage = array();
|
||||
public $storage = array();
|
||||
|
||||
/**
|
||||
* Which cache bin to store query results in.
|
||||
|
|
|
@ -137,7 +137,7 @@ class Time extends CachePluginBase {
|
|||
foreach ($custom_fields as $field) {
|
||||
$cache_options = $form_state->getValue('cache_options');
|
||||
if ($cache_options[$field] == 'custom' && !is_numeric($cache_options[$field . '_custom'])) {
|
||||
$form_state->setError($form[$field .'_custom'], $this->t('Custom time values must be numeric.'));
|
||||
$form_state->setError($form[$field . '_custom'], $this->t('Custom time values must be numeric.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
|
|||
*
|
||||
* @var \Drupal\views\ViewExecutable
|
||||
*/
|
||||
var $view = NULL;
|
||||
public $view = NULL;
|
||||
|
||||
/**
|
||||
* An array of instantiated handlers used in this display.
|
||||
|
@ -2216,6 +2216,10 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
|
|||
$return = array();
|
||||
foreach ($this->getHandlers($area) as $key => $area_handler) {
|
||||
if ($area_render = $area_handler->render($empty)) {
|
||||
if (isset($area_handler->position)) {
|
||||
// Fix weight of area.
|
||||
$area_render['#weight'] = $area_handler->position;
|
||||
}
|
||||
$return[$key] = $area_render;
|
||||
}
|
||||
}
|
||||
|
@ -2666,14 +2670,12 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
|
|||
* TRUE if the base table is of a translatable entity type, FALSE otherwise.
|
||||
*/
|
||||
protected function isBaseTableTranslatable() {
|
||||
$view_base_table = $this->view->storage->get('base_table');
|
||||
$views_data = Views::viewsData()->get($view_base_table);
|
||||
if (!empty($views_data['table']['entity type'])) {
|
||||
$entity_type_id = $views_data['table']['entity type'];
|
||||
return \Drupal::entityManager()->getDefinition($entity_type_id)->isTranslatable();
|
||||
if ($entity_type = $this->view->getBaseEntityType()) {
|
||||
return $entity_type->isTranslatable();
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -545,7 +545,6 @@ interface DisplayPluginInterface {
|
|||
*
|
||||
* @return bool
|
||||
* Returns whether the identifier is unique on all handlers.
|
||||
*
|
||||
*/
|
||||
public function isIdentifierUnique($id, $identifier);
|
||||
|
||||
|
|
|
@ -175,4 +175,5 @@ class EntityReference extends DisplayPluginBase {
|
|||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1030,15 +1030,27 @@ class Field extends FieldPluginBase implements CacheableDependencyInterface, Mul
|
|||
|
||||
$field_item_definition = $field_item_list->getFieldDefinition();
|
||||
|
||||
if ($field_item_definition->getFieldStorageDefinition()->getCardinality() == 1) {
|
||||
return $field ? $field_item_list->$field : $field_item_list->value;
|
||||
}
|
||||
|
||||
$values = [];
|
||||
foreach ($field_item_list as $field_item) {
|
||||
$values[] = $field ? $field_item->$field : $field_item->value;
|
||||
/** @var \Drupal\Core\Field\FieldItemInterface $field_item */
|
||||
if ($field) {
|
||||
$values[] = $field_item->$field;
|
||||
}
|
||||
// Find the value using the main property of the field. If no main
|
||||
// property is provided fall back to 'value'.
|
||||
elseif ($main_property_name = $field_item->mainPropertyName()) {
|
||||
$values[] = $field_item->{$main_property_name};
|
||||
}
|
||||
else {
|
||||
$values[] = $field_item->value;
|
||||
}
|
||||
}
|
||||
if ($field_item_definition->getFieldStorageDefinition()->getCardinality() == 1) {
|
||||
return reset($values);
|
||||
}
|
||||
else {
|
||||
return $values;
|
||||
}
|
||||
return $values;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -132,7 +132,6 @@ interface FieldHandlerInterface extends ViewsHandlerInterface {
|
|||
* An object containing all retrieved values.
|
||||
* @param string $field
|
||||
* Optional name of the field where the value is stored.
|
||||
*
|
||||
*/
|
||||
public function getValue(ResultRow $values, $field = NULL);
|
||||
|
||||
|
@ -153,7 +152,6 @@ interface FieldHandlerInterface extends ViewsHandlerInterface {
|
|||
*
|
||||
* @param \Drupal\views\ResultRow[] $values
|
||||
* An array of all ResultRow objects returned from the query.
|
||||
*
|
||||
*/
|
||||
public function preRender(&$values);
|
||||
|
||||
|
@ -167,7 +165,6 @@ interface FieldHandlerInterface extends ViewsHandlerInterface {
|
|||
* The rendered output. If the output is safe it will be wrapped in an
|
||||
* object that implements MarkupInterface. If it is empty or unsafe it
|
||||
* will be a string.
|
||||
*
|
||||
*/
|
||||
public function render(ResultRow $values);
|
||||
|
||||
|
@ -204,7 +201,6 @@ interface FieldHandlerInterface extends ViewsHandlerInterface {
|
|||
* The advanced rendered output. If the output is safe it will be wrapped in
|
||||
* an object that implements MarkupInterface. If it is empty or unsafe
|
||||
* it will be a string.
|
||||
*
|
||||
*/
|
||||
public function advancedRender(ResultRow $values);
|
||||
|
||||
|
|
|
@ -68,8 +68,8 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
|
|||
*/
|
||||
const RENDER_TEXT_PHASE_EMPTY = 2;
|
||||
|
||||
var $field_alias = 'unknown';
|
||||
var $aliases = array();
|
||||
public $field_alias = 'unknown';
|
||||
public $aliases = array();
|
||||
|
||||
/**
|
||||
* The field value prior to any rewriting.
|
||||
|
@ -85,7 +85,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
var $additional_fields = array();
|
||||
public $additional_fields = array();
|
||||
|
||||
/**
|
||||
* The link generator.
|
||||
|
@ -1717,13 +1717,13 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
|
|||
$display = $this->view->display_handler->display;
|
||||
|
||||
if (!empty($display)) {
|
||||
$themes[] = $hook . '__' . $this->view->storage->id() . '__' . $display['id'] . '__' . $this->options['id'];
|
||||
$themes[] = $hook . '__' . $this->view->storage->id() . '__' . $display['id'];
|
||||
$themes[] = $hook . '__' . $this->view->storage->id() . '__' . $display['id'] . '__' . $this->options['id'];
|
||||
$themes[] = $hook . '__' . $this->view->storage->id() . '__' . $display['id'];
|
||||
$themes[] = $hook . '__' . $display['id'] . '__' . $this->options['id'];
|
||||
$themes[] = $hook . '__' . $display['id'];
|
||||
if ($display['id'] != $display['display_plugin']) {
|
||||
$themes[] = $hook . '__' . $this->view->storage->id() . '__' . $display['display_plugin'] . '__' . $this->options['id'];
|
||||
$themes[] = $hook . '__' . $this->view->storage->id() . '__' . $display['display_plugin'];
|
||||
$themes[] = $hook . '__' . $this->view->storage->id() . '__' . $display['display_plugin'] . '__' . $this->options['id'];
|
||||
$themes[] = $hook . '__' . $this->view->storage->id() . '__' . $display['display_plugin'];
|
||||
$themes[] = $hook . '__' . $display['display_plugin'] . '__' . $this->options['id'];
|
||||
$themes[] = $hook . '__' . $display['display_plugin'];
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ abstract class PrerenderList extends FieldPluginBase implements MultiItemsFieldH
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
var $items = array();
|
||||
public $items = array();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -44,9 +44,9 @@ class BooleanOperator extends FilterPluginBase {
|
|||
// exposed filter options
|
||||
protected $alwaysMultiple = TRUE;
|
||||
// Don't display empty space where the operator would be.
|
||||
var $no_operator = TRUE;
|
||||
public $no_operator = TRUE;
|
||||
// Whether to accept NULL as a false value or not
|
||||
var $accept_null = FALSE;
|
||||
public $accept_null = FALSE;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class Combine extends StringFilter {
|
|||
/**
|
||||
* @var views_plugin_query_default
|
||||
*/
|
||||
var $query;
|
||||
public $query;
|
||||
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
|
@ -118,9 +118,10 @@ class Combine extends StringFilter {
|
|||
return $errors;
|
||||
}
|
||||
|
||||
// By default things like opEqual uses add_where, that doesn't support
|
||||
// complex expressions, so override all operators.
|
||||
|
||||
/**
|
||||
* By default things like opEqual uses add_where, that doesn't support
|
||||
* complex expressions, so override opEqual (and all operators below).
|
||||
*/
|
||||
function opEqual($expression) {
|
||||
$placeholder = $this->placeholder();
|
||||
$operator = $this->operator();
|
||||
|
|
|
@ -48,17 +48,17 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
|
|||
* Contains the actual value of the field,either configured in the views ui
|
||||
* or entered in the exposed filters.
|
||||
*/
|
||||
var $value = NULL;
|
||||
public $value = NULL;
|
||||
|
||||
/**
|
||||
* Contains the operator which is used on the query.
|
||||
*/
|
||||
var $operator = '=';
|
||||
public $operator = '=';
|
||||
|
||||
/**
|
||||
* Contains the information of the selected item in a grouped filter.
|
||||
*/
|
||||
var $group_info = NULL;
|
||||
public $group_info = NULL;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
|
@ -70,13 +70,13 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
|
|||
* @var bool
|
||||
* Disable the possibility to use operators.
|
||||
*/
|
||||
var $no_operator = FALSE;
|
||||
public $no_operator = FALSE;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* Disable the possibility to allow a exposed input to be optional.
|
||||
*/
|
||||
var $always_required = FALSE;
|
||||
public $always_required = FALSE;
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\views\Plugin\views\HandlerBase::init().
|
||||
|
@ -1227,7 +1227,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Transform the input from a grouped filter into a standard filter.
|
||||
*
|
||||
* When a filter is a group, find the set of operator and values
|
||||
|
|
|
@ -79,4 +79,5 @@ class LanguageFilter extends InOperator implements ContainerFactoryPluginInterfa
|
|||
|
||||
parent::query();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class ManyToOne extends InOperator {
|
|||
*
|
||||
* Stores the Helper object which handles the many_to_one complexity.
|
||||
*/
|
||||
var $helper = NULL;
|
||||
public $helper = NULL;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -95,5 +95,4 @@ class Full extends SqlBase {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ use Drupal\views\Plugin\views\PluginBase;
|
|||
*/
|
||||
abstract class PagerPluginBase extends PluginBase {
|
||||
|
||||
var $current_page = NULL;
|
||||
public $current_page = NULL;
|
||||
|
||||
var $total_items = 0;
|
||||
public $total_items = 0;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -38,7 +38,7 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
|
|||
*
|
||||
* @var views_plugin_pager
|
||||
*/
|
||||
var $pager = NULL;
|
||||
public $pager = NULL;
|
||||
|
||||
/**
|
||||
* Stores the limit of items that should be requested in the query.
|
||||
|
@ -62,7 +62,7 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
|
|||
* @param view $view
|
||||
* The view which is executed.
|
||||
*/
|
||||
function alter(ViewExecutable $view) { }
|
||||
public function alter(ViewExecutable $view) { }
|
||||
|
||||
/**
|
||||
* Builds the necessary info to execute the query.
|
||||
|
@ -70,7 +70,7 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
|
|||
* @param view $view
|
||||
* The view which is executed.
|
||||
*/
|
||||
function build(ViewExecutable $view) { }
|
||||
public function build(ViewExecutable $view) { }
|
||||
|
||||
/**
|
||||
* Executes the query and fills the associated view object with according
|
||||
|
@ -85,7 +85,7 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
|
|||
* @param view $view
|
||||
* The view which is executed.
|
||||
*/
|
||||
function execute(ViewExecutable $view) { }
|
||||
public function execute(ViewExecutable $view) { }
|
||||
|
||||
/**
|
||||
* Add a signature to the query, if such a thing is feasible.
|
||||
|
@ -160,7 +160,7 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
|
|||
* @param $where
|
||||
* 'where' or 'having'.
|
||||
*
|
||||
* @return $group
|
||||
* @return
|
||||
* The group ID generated.
|
||||
*/
|
||||
public function setWhereGroup($type = 'AND', $group = NULL, $where = 'where') {
|
||||
|
@ -231,7 +231,7 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
|
|||
* An appropriate query expression pointing to the date field.
|
||||
* @param string $format
|
||||
* A format string for the result, like 'Y-m-d H:i:s'.
|
||||
* @param boolean $string_date
|
||||
* @param bool $string_date
|
||||
* For certain databases, date format functions vary depending on string or
|
||||
* numeric storage.
|
||||
*
|
||||
|
|
|
@ -35,26 +35,26 @@ class Sql extends QueryPluginBase {
|
|||
/**
|
||||
* Holds an array of tables and counts added so that we can create aliases
|
||||
*/
|
||||
var $tables = array();
|
||||
public $tables = array();
|
||||
|
||||
/**
|
||||
* Holds an array of relationships, which are aliases of the primary
|
||||
* table that represent different ways to join the same table in.
|
||||
*/
|
||||
var $relationships = array();
|
||||
public $relationships = array();
|
||||
|
||||
/**
|
||||
* An array of sections of the WHERE query. Each section is in itself
|
||||
* an array of pieces and a flag as to whether or not it should be AND
|
||||
* or OR.
|
||||
*/
|
||||
var $where = array();
|
||||
public $where = array();
|
||||
/**
|
||||
* An array of sections of the HAVING query. Each section is in itself
|
||||
* an array of pieces and a flag as to whether or not it should be AND
|
||||
* or OR.
|
||||
*/
|
||||
var $having = array();
|
||||
public $having = array();
|
||||
/**
|
||||
* The default operator to use when connecting the WHERE groups. May be
|
||||
* AND or OR.
|
||||
|
@ -64,23 +64,23 @@ class Sql extends QueryPluginBase {
|
|||
/**
|
||||
* A simple array of order by clauses.
|
||||
*/
|
||||
var $orderby = array();
|
||||
public $orderby = array();
|
||||
|
||||
/**
|
||||
* A simple array of group by clauses.
|
||||
*/
|
||||
var $groupby = array();
|
||||
public $groupby = array();
|
||||
|
||||
|
||||
/**
|
||||
* An array of fields.
|
||||
*/
|
||||
var $fields = array();
|
||||
public $fields = array();
|
||||
|
||||
/**
|
||||
* A flag as to whether or not to make the primary field distinct.
|
||||
*/
|
||||
var $distinct = FALSE;
|
||||
public $distinct = FALSE;
|
||||
|
||||
protected $hasAggregate = FALSE;
|
||||
|
||||
|
@ -97,7 +97,7 @@ class Sql extends QueryPluginBase {
|
|||
/**
|
||||
* Query tags which will be passed over to the dbtng query object.
|
||||
*/
|
||||
var $tags = array();
|
||||
public $tags = array();
|
||||
|
||||
/**
|
||||
* Is the view marked as not distinct.
|
||||
|
@ -337,7 +337,7 @@ class Sql extends QueryPluginBase {
|
|||
* @param $alias
|
||||
* A specific alias to use, rather than the default alias.
|
||||
*
|
||||
* @return $alias
|
||||
* @return string
|
||||
* The alias of the table; this alias can be used to access information
|
||||
* about the table and should always be used to refer to the table when
|
||||
* adding parts to the query. Or FALSE if the table was not able to be
|
||||
|
@ -376,7 +376,7 @@ class Sql extends QueryPluginBase {
|
|||
* @param $alias
|
||||
* A specific alias to use, rather than the default alias.
|
||||
*
|
||||
* @return $alias
|
||||
* @return string
|
||||
* The alias of the table; this alias can be used to access information
|
||||
* about the table and should always be used to refer to the table when
|
||||
* adding parts to the query. Or FALSE if the table was not able to be
|
||||
|
@ -723,7 +723,7 @@ class Sql extends QueryPluginBase {
|
|||
* - aggregate: Set to TRUE to indicate that this value should be
|
||||
* aggregated in a GROUP BY.
|
||||
*
|
||||
* @return $name
|
||||
* @return string
|
||||
* The name that this field can be referred to as. Usually this is the alias.
|
||||
*/
|
||||
public function addField($table, $field, $alias = '', $params = array()) {
|
||||
|
@ -993,7 +993,7 @@ class Sql extends QueryPluginBase {
|
|||
/**
|
||||
* Generates a unique placeholder used in the db query.
|
||||
*/
|
||||
function placeholder($base = 'views') {
|
||||
public function placeholder($base = 'views') {
|
||||
static $placeholders = array();
|
||||
if (!isset($placeholders[$base])) {
|
||||
$placeholders[$base] = 0;
|
||||
|
@ -1332,14 +1332,14 @@ class Sql extends QueryPluginBase {
|
|||
/**
|
||||
* Let modules modify the query just prior to finalizing it.
|
||||
*/
|
||||
function alter(ViewExecutable $view) {
|
||||
public function alter(ViewExecutable $view) {
|
||||
\Drupal::moduleHandler()->invokeAll('views_query_alter', array($view, $this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the necessary info to execute the query.
|
||||
*/
|
||||
function build(ViewExecutable $view) {
|
||||
public function build(ViewExecutable $view) {
|
||||
// Make the query distinct if the option was set.
|
||||
if (!empty($this->options['distinct'])) {
|
||||
$this->setDistinct(TRUE);
|
||||
|
@ -1364,7 +1364,7 @@ class Sql extends QueryPluginBase {
|
|||
* Values to set: $view->result, $view->total_rows, $view->execute_time,
|
||||
* $view->current_page.
|
||||
*/
|
||||
function execute(ViewExecutable $view) {
|
||||
public function execute(ViewExecutable $view) {
|
||||
$query = $view->build_info['query'];
|
||||
$count_query = $view->build_info['count_query'];
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
*
|
||||
* @ViewsRelationship("entity_reverse")
|
||||
*/
|
||||
class EntityReverse extends RelationshipPluginBase {
|
||||
class EntityReverse extends RelationshipPluginBase {
|
||||
|
||||
/**
|
||||
* Constructs an EntityReverse object.
|
||||
|
|
|
@ -203,8 +203,8 @@ class GroupwiseMax extends RelationshipPluginBase {
|
|||
}
|
||||
|
||||
// Get the namespace string.
|
||||
$temp_view->namespace = (!empty($options['subquery_namespace'])) ? '_'. $options['subquery_namespace'] : '_INNER';
|
||||
$this->subquery_namespace = (!empty($options['subquery_namespace'])) ? '_'. $options['subquery_namespace'] : 'INNER';
|
||||
$temp_view->namespace = (!empty($options['subquery_namespace'])) ? '_' . $options['subquery_namespace'] : '_INNER';
|
||||
$this->subquery_namespace = (!empty($options['subquery_namespace'])) ? '_' . $options['subquery_namespace'] : 'INNER';
|
||||
|
||||
// The value we add here does nothing, but doing this adds the right tables
|
||||
// and puts in a WHERE clause with a placeholder we can grab later.
|
||||
|
|
|
@ -53,4 +53,5 @@ class EntityReference extends Fields {
|
|||
|
||||
return parent::preRender($row);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -100,4 +100,5 @@ class EntityReference extends StylePluginBase {
|
|||
public function evenEmpty() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -720,7 +720,7 @@ abstract class StylePluginBase extends PluginBase {
|
|||
$fields = $this->view->field;
|
||||
$rendered_fields = &$this->rendered_fields[$index];
|
||||
$post_render_tokens = [];
|
||||
foreach ($field_ids as $id) {
|
||||
foreach ($field_ids as $id) {
|
||||
$rendered_fields[$id] = $data[$id]['#markup'];
|
||||
$tokens = $fields[$id]->postRender($row, $rendered_fields[$id]);
|
||||
if ($tokens) {
|
||||
|
|
|
@ -20,4 +20,5 @@ use Drupal\Component\Render\MarkupTrait;
|
|||
*/
|
||||
final class ViewsRenderPipelineMarkup implements MarkupInterface, \Countable {
|
||||
use MarkupTrait;
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use Drupal\language\Entity\ConfigurableLanguage;
|
|||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
use Symfony\Component\CssSelector\CssSelector;
|
||||
use Symfony\Component\CssSelector\CssSelectorConverter;
|
||||
|
||||
/**
|
||||
* Tests the rendering of fields (base fields) and their translations.
|
||||
|
@ -171,8 +171,8 @@ class FieldEntityTranslationTest extends ViewTestBase {
|
|||
$rows = $this->cssSelect('div.views-row');
|
||||
foreach ($rows as $row) {
|
||||
$actual[] = [
|
||||
'title' => (string) $row->xpath(CssSelector::toXPath('.views-field-title span.field-content a'))[0],
|
||||
'sticky' => (string) $row->xpath(CssSelector::toXPath('.views-field-sticky span.field-content'))[0],
|
||||
'title' => (string) $row->xpath((new CssSelectorConverter())->toXPath('.views-field-title span.field-content a'))[0],
|
||||
'sticky' => (string) $row->xpath((new CssSelectorConverter())->toXPath('.views-field-sticky span.field-content'))[0],
|
||||
];
|
||||
}
|
||||
$this->assertEqual($actual, $expected);
|
||||
|
|
|
@ -58,7 +58,7 @@ class AreaTest extends HandlerTestBase {
|
|||
$types = array('header', 'footer', 'empty');
|
||||
$labels = array();
|
||||
foreach ($types as $type) {
|
||||
$edit_path = 'admin/structure/views/nojs/handler/test_example_area/default/' . $type .'/test_example';
|
||||
$edit_path = 'admin/structure/views/nojs/handler/test_example_area/default/' . $type . '/test_example';
|
||||
|
||||
// First setup an empty label.
|
||||
$this->drupalPostForm($edit_path, array(), t('Apply'));
|
||||
|
|
|
@ -102,4 +102,5 @@ class DisplayAttachmentTest extends PluginTestBase {
|
|||
$result = $this->xpath('//div[contains(@class, "attachment-after")]');
|
||||
$this->assertEqual(count($result), 0, 'The attachment_2 is not rendered.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -94,4 +94,5 @@ class MenuLinkTest extends ViewTestBase {
|
|||
$this->assertText('Primary level node');
|
||||
$this->assertText('Secondary level view page');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -156,4 +156,5 @@ class NumericFormatPluralTest extends ViewTestBase {
|
|||
|
||||
return $file;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -449,4 +449,5 @@ class PagerTest extends PluginTestBase {
|
|||
);
|
||||
return $this->localeStorage->createTranslation($values)->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class PluginBaseTest extends KernelTestBase {
|
|||
/**
|
||||
* @var TestPluginBase
|
||||
*/
|
||||
var $testPluginBase;
|
||||
protected $testPluginBase;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
|
|
@ -30,4 +30,5 @@ class ViewsFormTest extends WebTestBase {
|
|||
$result = (bool) preg_match('#<form[^>]*?>(?!/form).*<form#s', $this->getRawContent());
|
||||
$this->assertFalse($result, 'The views form element is not nested.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class TestHelperPlugin extends PluginBase {
|
|||
/**
|
||||
* Calls the protected method setOptionDefaults().
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\PluginBase::setOptionDefaults().
|
||||
* @see \Drupal\views\Plugin\views\PluginBase::setOptionDefaults()
|
||||
*/
|
||||
public function testSetOptionDefaults(&$storage, $options, $level = 0) {
|
||||
$this->setOptionDefaults($storage, $options, $level);
|
||||
|
|
|
@ -117,7 +117,7 @@ abstract class ViewKernelTestBase extends KernelTestBase {
|
|||
$view->setDisplay();
|
||||
$view->preExecute($args);
|
||||
$view->execute();
|
||||
$verbose_message = '<pre>Executed view: ' . ((string) $view->build_info['query']). '</pre>';
|
||||
$verbose_message = '<pre>Executed view: ' . ((string) $view->build_info['query']) . '</pre>';
|
||||
if ($view->build_info['query'] instanceof SelectInterface) {
|
||||
$verbose_message .= '<pre>Arguments: ' . print_r($view->build_info['query']->getArguments(), TRUE) . '</pre>';
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ abstract class ViewTestBase extends WebTestBase {
|
|||
$view->setDisplay();
|
||||
$view->preExecute($args);
|
||||
$view->execute();
|
||||
$verbose_message = '<pre>Executed view: ' . ((string) $view->build_info['query']). '</pre>';
|
||||
$verbose_message = '<pre>Executed view: ' . ((string) $view->build_info['query']) . '</pre>';
|
||||
if ($view->build_info['query'] instanceof SelectInterface) {
|
||||
$verbose_message .= '<pre>Arguments: ' . print_r($view->build_info['query']->getArguments(), TRUE) . '</pre>';
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ class BasicTest extends WizardTestBase {
|
|||
/**
|
||||
* Tests default plugin values are populated from the wizard form.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\display\DisplayPluginBase::mergeDefaults().
|
||||
* @see \Drupal\views\Plugin\views\display\DisplayPluginBase::mergeDefaults()
|
||||
*/
|
||||
public function testWizardDefaultValues() {
|
||||
$random_id = strtolower($this->randomMachineName(16));
|
||||
|
|
|
@ -66,5 +66,4 @@ interface ViewEntityInterface extends ConfigEntityInterface {
|
|||
*/
|
||||
public function addDisplay($plugin_id = 'page', $title = NULL, $id = NULL);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -428,6 +428,13 @@ class ViewExecutable implements \Serializable {
|
|||
*/
|
||||
protected $routeProvider;
|
||||
|
||||
/**
|
||||
* The entity type of the base table, if available.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeInterface|false
|
||||
*/
|
||||
protected $baseEntityType;
|
||||
|
||||
/**
|
||||
* Constructs a new ViewExecutable object.
|
||||
*
|
||||
|
@ -961,6 +968,27 @@ class ViewExecutable implements \Serializable {
|
|||
return $base_tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the entity type of the base table, if available.
|
||||
*
|
||||
* @return \Drupal\Core\Entity\EntityType|false
|
||||
* The entity type of the base table, or FALSE if none exists.
|
||||
*/
|
||||
public function getBaseEntityType() {
|
||||
if (!isset($this->baseEntityType)) {
|
||||
$view_base_table = $this->storage->get('base_table');
|
||||
$views_data = $this->viewsData->get($view_base_table);
|
||||
if (!empty($views_data['table']['entity type'])) {
|
||||
$entity_type_id = $views_data['table']['entity type'];
|
||||
$this->baseEntityType = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
|
||||
}
|
||||
else {
|
||||
$this->baseEntityType = FALSE;
|
||||
}
|
||||
}
|
||||
return $this->baseEntityType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the preQuery() on all active handlers.
|
||||
*/
|
||||
|
@ -2034,7 +2062,13 @@ class ViewExecutable implements \Serializable {
|
|||
$defaults = $reflection->getDefaultProperties();
|
||||
// The external dependencies should not be reset. This is not generated by
|
||||
// the execution of a view.
|
||||
unset($defaults['storage'], $defaults['user'], $defaults['request'], $defaults['routeProvider']);
|
||||
unset(
|
||||
$defaults['storage'],
|
||||
$defaults['user'],
|
||||
$defaults['request'],
|
||||
$defaults['routeProvider'],
|
||||
$defaults['viewsData']
|
||||
);
|
||||
|
||||
foreach ($defaults as $property => $default) {
|
||||
$this->{$property} = $default;
|
||||
|
|
|
@ -319,4 +319,5 @@ class ViewsData {
|
|||
$this->fullyLoaded = FALSE;
|
||||
Cache::invalidateTags(array('views_data'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
langcode: en
|
||||
status: true
|
||||
id: test_area_order
|
||||
label: ''
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: views_test_data
|
||||
base_field: nid
|
||||
core: '8'
|
||||
display:
|
||||
default:
|
||||
display_options:
|
||||
defaults:
|
||||
fields: false
|
||||
pager: false
|
||||
sorts: false
|
||||
header:
|
||||
entity_block_2:
|
||||
field: entity_block
|
||||
id: entity_block
|
||||
table: views
|
||||
target: 'bartik_powered'
|
||||
view_mode: full
|
||||
plugin_id: entity
|
||||
entity_block_1:
|
||||
field: entity_block
|
||||
id: entity_block
|
||||
table: views
|
||||
target: 'bartik_branding'
|
||||
view_mode: full
|
||||
plugin_id: entity
|
||||
fields:
|
||||
id:
|
||||
field: id
|
||||
id: id
|
||||
relationship: none
|
||||
table: views_test_data
|
||||
plugin_id: numeric
|
||||
arguments:
|
||||
id:
|
||||
id: id
|
||||
table: views_test_data
|
||||
field: id
|
||||
plugin_id: numeric
|
||||
pager:
|
||||
options:
|
||||
offset: 0
|
||||
type: none
|
||||
display_plugin: default
|
||||
display_title: Master
|
||||
id: default
|
||||
position: 0
|
|
@ -23,6 +23,13 @@ display:
|
|||
plugin_id: field
|
||||
entity_type: entity_test
|
||||
entity_field: id
|
||||
field_test_multiple:
|
||||
id: field_test_multiple
|
||||
table: entity_test__field_test_multiple
|
||||
field: field_test_multiple
|
||||
plugin_id: field
|
||||
entity_type: entity_test
|
||||
entity_field: field_test_multiple
|
||||
field_test:
|
||||
id: field_test
|
||||
table: entity_test__field_test
|
||||
|
@ -30,6 +37,13 @@ display:
|
|||
plugin_id: field
|
||||
entity_type: entity_test
|
||||
entity_field: field_test
|
||||
user_id:
|
||||
id: user_id
|
||||
table: entity_test
|
||||
field: user_id
|
||||
plugin_id: field
|
||||
entity_type: entity_test
|
||||
entity_field: user_id
|
||||
style:
|
||||
type: html_list
|
||||
sorts:
|
||||
|
|
|
@ -37,4 +37,5 @@ class ViewsTestDataElementEmbedForm extends FormBase {
|
|||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
use Drupal\simpletest\ContentTypeCreationTrait;
|
||||
use Drupal\simpletest\NodeCreationTrait;
|
||||
|
||||
/**
|
||||
* Tests the basic AJAX functionality of Views exposed forms.
|
||||
*
|
||||
* @group views
|
||||
*/
|
||||
class ExposedFilterAJAXTest extends JavascriptTestBase {
|
||||
|
||||
use ContentTypeCreationTrait;
|
||||
use NodeCreationTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'views'];
|
||||
|
||||
/**
|
||||
* Tests if exposed filtering via AJAX works for the "Content" View.
|
||||
*/
|
||||
public function testExposedFiltering() {
|
||||
// Enable AJAX on the /admin/content View.
|
||||
\Drupal::configFactory()->getEditable('views.view.content')
|
||||
->set('display.default.display_options.use_ajax', TRUE)
|
||||
->save();
|
||||
|
||||
// Create a Content type and two test nodes.
|
||||
$this->createContentType(['type' => 'page']);
|
||||
$this->createNode(['title' => 'Page One']);
|
||||
$this->createNode(['title' => 'Page Two']);
|
||||
|
||||
// Create a user privileged enough to use exposed filters and view content.
|
||||
$user = $this->drupalCreateUser([
|
||||
'administer site configuration',
|
||||
'access content',
|
||||
'access content overview',
|
||||
]);
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Visit the View page.
|
||||
$this->drupalGet('admin/content');
|
||||
|
||||
$session = $this->getSession();
|
||||
|
||||
// Ensure that the Content we're testing for is present.
|
||||
$html = $session->getPage()->getHtml();
|
||||
$this->assertContains('Page One', $html);
|
||||
$this->assertContains('Page Two', $html);
|
||||
|
||||
// Search for "Page One".
|
||||
$this->submitForm(['title' => 'Page One'], t('Filter'));
|
||||
$this->waitForAjaxToFinish();
|
||||
|
||||
// Verify that only the "Page One" Node is present.
|
||||
$html = $session->getPage()->getHtml();
|
||||
$this->assertContains('Page One', $html);
|
||||
$this->assertNotContains('Page Two', $html);
|
||||
|
||||
// Search for "Page Two".
|
||||
$this->submitForm(['title' => 'Page Two'], t('Filter'));
|
||||
$this->waitForAjaxToFinish();
|
||||
|
||||
// Verify that only the "Page Two" Node is present.
|
||||
$html = $session->getPage()->getHtml();
|
||||
$this->assertContains('Page Two', $html);
|
||||
$this->assertNotContains('Page One', $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for jQuery to become active and animations to complete.
|
||||
*/
|
||||
protected function waitForAjaxToFinish() {
|
||||
$condition = "(0 === jQuery.active && 0 === jQuery(':animated').length)";
|
||||
$this->assertJsCondition($condition, 10000);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Kernel\Handler;
|
||||
|
||||
use Drupal\block\Entity\Block;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests the view area handler.
|
||||
*
|
||||
* @group views
|
||||
* @see \Drupal\views\Plugin\views\area\View
|
||||
*/
|
||||
class AreaOrderTest extends ViewsKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('user', 'block');
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_area_order');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUpFixtures() {
|
||||
Block::create(
|
||||
[
|
||||
'id' => 'bartik_branding',
|
||||
'theme' => 'bartik',
|
||||
'plugin' => 'system_branding_block',
|
||||
'weight' => 1,
|
||||
]
|
||||
)->save();
|
||||
|
||||
Block::create(
|
||||
[
|
||||
'id' => 'bartik_powered',
|
||||
'theme' => 'bartik',
|
||||
'plugin' => 'system_powered_by_block',
|
||||
'weight' => 2,
|
||||
]
|
||||
)->save();
|
||||
|
||||
parent::setUpFixtures();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the order of the handlers.
|
||||
*/
|
||||
public function testAreaOrder() {
|
||||
$renderer = $this->container->get('renderer');
|
||||
$view = Views::getView('test_area_order');
|
||||
$renderable = $view->buildRenderable();
|
||||
$output = $this->render($renderable);
|
||||
|
||||
$position_powered = strpos($output, 'block-bartik-powered');
|
||||
$position_branding = strpos($output, 'block-bartik-branding');
|
||||
|
||||
$this->assertNotEquals(0, $position_powered, 'ID bartik-powered found.');
|
||||
$this->assertNotEquals(0, $position_branding, 'ID bartik-branding found');
|
||||
|
||||
// Make sure "powered" is before "branding", so it reflects the position
|
||||
// in the configuration, and not the weight of the blocks.
|
||||
$this->assertTrue($position_powered < $position_branding, 'Block bartik-powered is positioned before block bartik-branding');
|
||||
}
|
||||
|
||||
}
|
|
@ -315,4 +315,5 @@ class ArgumentDateTest extends ViewsKernelTestBase {
|
|||
$expected = array();
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -84,7 +84,9 @@ class FieldCounterTest extends ViewsKernelTestBase {
|
|||
$this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
|
||||
}
|
||||
|
||||
// @TODO: Write tests for pager.
|
||||
/**
|
||||
* @todo: Write tests for pager.
|
||||
*/
|
||||
function testPager() {
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use Drupal\field\Entity\FieldStorageConfig;
|
|||
use Drupal\user\Entity\User;
|
||||
use Drupal\views\Plugin\views\field\Field;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
|
@ -62,12 +63,15 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp();
|
||||
// First setup the needed entity types before installing the views.
|
||||
parent::setUp(FALSE);
|
||||
|
||||
$this->installEntitySchema('entity_test');
|
||||
$this->installEntitySchema('user');
|
||||
$this->installEntitySchema('entity_test');
|
||||
$this->installEntitySchema('entity_test_rev');
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
|
||||
|
||||
// Bypass any field access.
|
||||
$this->adminUser = User::create(['name' => $this->randomString()]);
|
||||
$this->adminUser->save();
|
||||
|
@ -546,4 +550,60 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
$this->assertEqual('', $executable->getStyle()->getField(6, 'field_test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests \Drupal\views\Plugin\views\field\Field::getValue
|
||||
*/
|
||||
public function testGetValueMethod() {
|
||||
$bundle = 'test_bundle';
|
||||
entity_test_create_bundle($bundle);
|
||||
|
||||
$field_multiple = FieldConfig::create([
|
||||
'field_name' => 'field_test_multiple',
|
||||
'entity_type' => 'entity_test',
|
||||
'bundle' => 'test_bundle',
|
||||
]);
|
||||
$field_multiple->save();
|
||||
|
||||
foreach ($this->entities as $entity) {
|
||||
$entity->delete();
|
||||
}
|
||||
|
||||
$this->entities = [];
|
||||
$this->entities[] = $entity = EntityTest::create([
|
||||
'type' => 'entity_test',
|
||||
'name' => 'test name',
|
||||
'user_id' => $this->testUsers[0]->id(),
|
||||
]);
|
||||
$entity->save();
|
||||
$this->entities[] = $entity = EntityTest::create([
|
||||
'type' => 'entity_test',
|
||||
'name' => 'test name 2',
|
||||
'user_id' => $this->testUsers[0]->id(),
|
||||
]);
|
||||
$entity->save();
|
||||
|
||||
$this->entities[] = $entity = EntityTest::create([
|
||||
'type' => $bundle,
|
||||
'name' => 'test name 3',
|
||||
'user_id' => $this->testUsers[0]->id(),
|
||||
'field_test_multiple' => [1, 2, 3],
|
||||
]);
|
||||
$entity->save();
|
||||
|
||||
$executable = Views::getView('test_field_field_test');
|
||||
$executable->execute();
|
||||
|
||||
$field_normal = $executable->field['field_test'];
|
||||
$field_entity_reference = $executable->field['user_id'];
|
||||
$field_multi_cardinality = $executable->field['field_test_multiple'];
|
||||
|
||||
$this->assertEquals($this->entities[0]->field_test->value, $field_normal->getValue($executable->result[0]));
|
||||
$this->assertEquals($this->entities[0]->user_id->target_id, $field_entity_reference->getValue($executable->result[0]));
|
||||
$this->assertEquals($this->entities[1]->field_test->value, $field_normal->getValue($executable->result[1]));
|
||||
$this->assertEquals($this->entities[1]->user_id->target_id, $field_entity_reference->getValue($executable->result[1]));
|
||||
$this->assertEquals([], $field_multi_cardinality->getValue($executable->result[0]));
|
||||
$this->assertEquals([], $field_multi_cardinality->getValue($executable->result[1]));
|
||||
$this->assertEquals([1, 2, 3], $field_multi_cardinality->getValue($executable->result[2]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class ViewsBlockTest extends ViewsKernelTestBase {
|
|||
/**
|
||||
* Tests that ViewsBlock::getMachineNameSuggestion() produces the right value.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\Block::getmachineNameSuggestion().
|
||||
* @see \Drupal\views\Plugin\Block::getmachineNameSuggestion()
|
||||
*/
|
||||
public function testMachineNameSuggestion() {
|
||||
$plugin_definition = array(
|
||||
|
|
|
@ -351,7 +351,13 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
$reflection = new \ReflectionClass($view);
|
||||
$defaults = $reflection->getDefaultProperties();
|
||||
// The storage and user should remain.
|
||||
unset($defaults['storage'], $defaults['user'], $defaults['request'], $defaults['routeProvider']);
|
||||
unset(
|
||||
$defaults['storage'],
|
||||
$defaults['user'],
|
||||
$defaults['request'],
|
||||
$defaults['routeProvider'],
|
||||
$defaults['viewsData']
|
||||
);
|
||||
|
||||
foreach ($defaults as $property => $default) {
|
||||
$this->assertIdentical($this->getProtectedProperty($view, $property), $default);
|
||||
|
|
|
@ -120,7 +120,7 @@ class ViewsKernelTestBase extends KernelTestBase {
|
|||
$view->setDisplay();
|
||||
$view->preExecute($args);
|
||||
$view->execute();
|
||||
$verbose_message = '<pre>Executed view: ' . ((string) $view->build_info['query']). '</pre>';
|
||||
$verbose_message = '<pre>Executed view: ' . ((string) $view->build_info['query']) . '</pre>';
|
||||
if ($view->build_info['query'] instanceof SelectInterface) {
|
||||
$verbose_message .= '<pre>Arguments: ' . print_r($view->build_info['query']->getArguments(), TRUE) . '</pre>';
|
||||
}
|
||||
|
|
|
@ -70,4 +70,5 @@ class WizardPluginBaseKernelTest extends ViewsKernelTestBase {
|
|||
$this->assertEqual($view->get('base_table'), 'views_test_data');
|
||||
$this->assertEqual($view->get('langcode'), 'it');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ use Drupal\Core\Field\Plugin\Field\FieldType\LanguageItem;
|
|||
use Drupal\Core\Field\Plugin\Field\FieldType\StringItem;
|
||||
use Drupal\Core\Field\Plugin\Field\FieldType\UriItem;
|
||||
use Drupal\Core\Field\Plugin\Field\FieldType\UuidItem;
|
||||
use Drupal\Core\TypedData\TypedDataManagerInterface;
|
||||
use Drupal\text\Plugin\Field\FieldType\TextLongItem;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\entity_test\Entity\EntityTestMul;
|
||||
|
@ -83,9 +84,7 @@ class EntityViewsDataTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
|
||||
|
||||
$typed_data_manager = $this->getMockBuilder('Drupal\Core\TypedData\TypedDataManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$typed_data_manager = $this->getMock(TypedDataManagerInterface::class);
|
||||
$typed_data_manager->expects($this->any())
|
||||
->method('createDataDefinition')
|
||||
->willReturn($this->getMock('Drupal\Core\TypedData\DataDefinitionInterface'));
|
||||
|
@ -962,6 +961,7 @@ class TestEntityViewsData extends EntityViewsData {
|
|||
public function setEntityType(EntityTypeInterface $entity_type) {
|
||||
$this->entityType = $entity_type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TestEntityType extends EntityType {
|
||||
|
|
|
@ -249,7 +249,9 @@ class PagerPluginBaseTest extends UnitTestCase {
|
|||
|
||||
}
|
||||
|
||||
// As StatementInterface extends \Traversable, which though always needs
|
||||
// an additional interface. The Statement class itself can't be mocked because
|
||||
// of its __wakeup function.
|
||||
/**
|
||||
* As StatementInterface extends \Traversable, which though always needs
|
||||
* an additional interface. The Statement class itself can't be mocked because
|
||||
* of its __wakeup function.
|
||||
*/
|
||||
interface TestStatementInterface extends StatementInterface, \Iterator {}
|
||||
|
|
|
@ -163,6 +163,7 @@ class EntityOperationsUnitTest extends UnitTestCase {
|
|||
$build = $this->plugin->render($result);
|
||||
$this->assertSame($expected_build, $build);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -833,12 +833,12 @@ function hook_views_pre_render(ViewExecutable $view) {
|
|||
* primary field will be a nid, you can do something like this:
|
||||
* @code
|
||||
* <!--post-FIELD-NID-->
|
||||
* @encode
|
||||
* @endcode
|
||||
* And then in the post-render, create an array with the text that should
|
||||
* go there:
|
||||
* @code
|
||||
* strtr($output, array('<!--post-FIELD-1-->' => 'output for FIELD of nid 1');
|
||||
* @encode
|
||||
* @endcode
|
||||
* All of the cached result data will be available in $view->result, as well,
|
||||
* so all ids used in the query should be discoverable.
|
||||
*
|
||||
|
|
|
@ -189,7 +189,7 @@ function views_theme($existing, $type, $theme, $path) {
|
|||
// Whenever we have a theme file, we include it directly so we can
|
||||
// auto-detect the theme function.
|
||||
if (isset($def['theme_file'])) {
|
||||
$include = \Drupal::root() . '/' . $module_dir. '/' . $def['theme_file'];
|
||||
$include = \Drupal::root() . '/' . $module_dir . '/' . $def['theme_file'];
|
||||
if (is_file($include)) {
|
||||
require_once $include;
|
||||
}
|
||||
|
|
|
@ -295,6 +295,12 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
|
|||
if (!$field_storage->getBundles()) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// Ignore custom storage too.
|
||||
if ($field_storage->hasCustomStorage()) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// Check whether the entity type storage is supported.
|
||||
$storage = _views_field_get_entity_type_storage($field_storage);
|
||||
if (!$storage) {
|
||||
|
|
Reference in a new issue