Update to Drupal 8.0.6. For more information, see https://www.drupal.org/drupal-8.0.6-release-notes
This commit is contained in:
parent
4297c64508
commit
b11a755ba8
159 changed files with 2340 additions and 543 deletions
|
@ -28,7 +28,7 @@ class EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterfac
|
|||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* Entity type for this views controller instance.
|
||||
* Entity type for this views data handler instance.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeInterface
|
||||
*/
|
||||
|
@ -68,7 +68,7 @@ class EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterfac
|
|||
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
||||
* The entity type to provide views integration for.
|
||||
* @param \Drupal\Core\Entity\Sql\SqlEntityStorageInterface $storage_controller
|
||||
* The storage controller used for this entity type.
|
||||
* The storage handler used for this entity type.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
|
|
|
@ -735,12 +735,12 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
|
|||
|
||||
// Determine if the string has 'or' operators (plus signs) or 'and'
|
||||
// operators (commas) and split the string accordingly.
|
||||
if (preg_match('/^([\w0-9-_]+[+ ]+)+[\w0-9-_]+$/u', $str)) {
|
||||
if (preg_match('/^([\w0-9-_\.]+[+ ]+)+[\w0-9-_\.]+$/u', $str)) {
|
||||
// The '+' character in a query string may be parsed as ' '.
|
||||
$operator = 'or';
|
||||
$value = preg_split('/[+ ]/', $str);
|
||||
}
|
||||
elseif (preg_match('/^([\w0-9-_]+[, ]+)*[\w0-9-_]+$/u', $str)) {
|
||||
elseif (preg_match('/^([\w0-9-_\.]+[, ]+)*[\w0-9-_\.]+$/u', $str)) {
|
||||
$operator = 'and';
|
||||
$value = explode(',', $str);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class NumericArgument extends ArgumentPluginBase {
|
|||
}
|
||||
|
||||
if (!empty($this->options['break_phrase'])) {
|
||||
$break = static::breakString($this->argument, TRUE);
|
||||
$break = static::breakString($this->argument, FALSE);
|
||||
$this->value = $break->value;
|
||||
$this->operator = $break->operator;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class NumericArgument extends ArgumentPluginBase {
|
|||
$this->ensureMyTable();
|
||||
|
||||
if (!empty($this->options['break_phrase'])) {
|
||||
$break = static::breakString($this->argument, TRUE);
|
||||
$break = static::breakString($this->argument, FALSE);
|
||||
$this->value = $break->value;
|
||||
$this->operator = $break->operator;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,8 @@ class EntityReference extends DisplayPluginBase {
|
|||
|
||||
// Make sure the id field is included in the results.
|
||||
$id_field = $this->view->storage->get('base_field');
|
||||
$this->id_field_alias = $this->view->query->addField($this->view->storage->get('base_table'), $id_field);
|
||||
$id_table = $this->view->storage->get('base_table');
|
||||
$this->id_field_alias = $this->view->query->addField($id_table, $id_field);
|
||||
|
||||
$options = $this->getOption('entity_reference_options');
|
||||
|
||||
|
@ -139,7 +140,8 @@ class EntityReference extends DisplayPluginBase {
|
|||
if (!empty($field_id)) {
|
||||
// Get the table and field names for the checked field.
|
||||
$field_handler = $this->view->field[$field_id];
|
||||
$field_alias = $this->view->query->addField($field_handler->table, $field_handler->realField);
|
||||
$table_alias = $this->view->query->ensureTable($field_handler->table, $field_handler->relationship);
|
||||
$field_alias = $this->view->query->addField($table_alias, $field_handler->realField);
|
||||
$field = $this->view->query->fields[$field_alias];
|
||||
// Add an OR condition for the field.
|
||||
$conditions->condition($field['table'] . '.' . $field['field'], $value, 'LIKE');
|
||||
|
@ -151,7 +153,7 @@ class EntityReference extends DisplayPluginBase {
|
|||
|
||||
// Add an IN condition for validation.
|
||||
if (!empty($options['ids'])) {
|
||||
$this->view->query->addWhere(0, $id_field, $options['ids'], 'IN');
|
||||
$this->view->query->addWhere(0, $id_table . '.' . $id_field, $options['ids'], 'IN');
|
||||
}
|
||||
|
||||
$this->view->setItemsPerPage($options['limit']);
|
||||
|
|
|
@ -1681,8 +1681,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
|
|||
* fields as a list. For example, the field that displays all terms
|
||||
* on a node might have tokens for the tid and the term.
|
||||
*
|
||||
* By convention, tokens should follow the format of {{ token
|
||||
* subtoken }}
|
||||
* By convention, tokens should follow the format of {{ token__subtoken }}
|
||||
* where token is the field ID and subtoken is the field. If the
|
||||
* field ID is terms, then the tokens might be {{ terms__tid }} and
|
||||
* {{ terms__name }}.
|
||||
|
|
|
@ -412,7 +412,6 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
|
|||
'#type' => 'submit',
|
||||
'#value' => $this->t('Grouped filters'),
|
||||
'#submit' => array(array($this, 'buildGroupForm')),
|
||||
'#attributes' => array('class' => array('use-ajax-submit')),
|
||||
);
|
||||
$form['group_button']['radios']['radios']['#default_value'] = 0;
|
||||
}
|
||||
|
@ -422,7 +421,6 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
|
|||
'#type' => 'submit',
|
||||
'#value' => $this->t('Single filter'),
|
||||
'#submit' => array(array($this, 'buildGroupForm')),
|
||||
'#attributes' => array('class' => array('use-ajax-submit')),
|
||||
);
|
||||
$form['group_button']['radios']['radios']['#default_value'] = 1;
|
||||
}
|
||||
|
@ -487,7 +485,6 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
|
|||
'#type' => 'submit',
|
||||
'#value' => $this->t('Expose filter'),
|
||||
'#submit' => array(array($this, 'displayExposedForm')),
|
||||
'#attributes' => array('class' => array('use-ajax-submit')),
|
||||
);
|
||||
$form['expose_button']['checkbox']['checkbox']['#default_value'] = 0;
|
||||
}
|
||||
|
@ -500,7 +497,6 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
|
|||
'#type' => 'submit',
|
||||
'#value' => $this->t('Hide filter'),
|
||||
'#submit' => array(array($this, 'displayExposedForm')),
|
||||
'#attributes' => array('class' => array('use-ajax-submit')),
|
||||
);
|
||||
$form['expose_button']['checkbox']['checkbox']['#default_value'] = 1;
|
||||
}
|
||||
|
@ -1075,7 +1071,6 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
|
|||
'#type' => 'submit',
|
||||
'#value' => $this->t('Add another item'),
|
||||
'#submit' => array(array($this, 'addGroupForm')),
|
||||
'#attributes' => array('class' => array('use-ajax-submit')),
|
||||
);
|
||||
|
||||
$js = array();
|
||||
|
|
|
@ -125,7 +125,6 @@ abstract class SortPluginBase extends HandlerBase implements CacheableDependency
|
|||
'#type' => 'submit',
|
||||
'#value' => $this->t('Expose sort'),
|
||||
'#submit' => array(array($this, 'displayExposedForm')),
|
||||
'#attributes' => array('class' => array('use-ajax-submit')),
|
||||
);
|
||||
$form['expose_button']['checkbox']['checkbox']['#default_value'] = 0;
|
||||
}
|
||||
|
@ -138,7 +137,6 @@ abstract class SortPluginBase extends HandlerBase implements CacheableDependency
|
|||
'#type' => 'submit',
|
||||
'#value' => $this->t('Hide sort'),
|
||||
'#submit' => array(array($this, 'displayExposedForm')),
|
||||
'#attributes' => array('class' => array('use-ajax-submit')),
|
||||
);
|
||||
$form['expose_button']['checkbox']['checkbox']['#default_value'] = 1;
|
||||
}
|
||||
|
|
|
@ -162,6 +162,37 @@ class HandlerTest extends ViewTestBase {
|
|||
$handlerBase = HandlerBase::breakString("$s1+$n2+$n3", TRUE);
|
||||
$this->assertEqualValue(array((int) $s1, $n2, $n3), $handlerBase);
|
||||
$this->assertEqual('or', $handlerBase->operator);
|
||||
|
||||
// Generate three random decimals which can be used below;
|
||||
$d1 = rand(0, 10) / 10;
|
||||
$d2 = rand(0, 10) / 10;
|
||||
$d3 = rand(0, 10) / 10;
|
||||
|
||||
// Test "or"s.
|
||||
$handlerBase = HandlerBase::breakString("$s1 $d1+$d2");
|
||||
$this->assertEqualValue(array($s1, $d1, $d2), $handlerBase);
|
||||
$this->assertEqual('or', $handlerBase->operator);
|
||||
|
||||
$handlerBase = HandlerBase::breakString("$s1+$d1+$d3");
|
||||
$this->assertEqualValue(array($s1, $d1, $d3), $handlerBase);
|
||||
$this->assertEqual('or', $handlerBase->operator);
|
||||
|
||||
$handlerBase = HandlerBase::breakString("$s1 $d2 $d3");
|
||||
$this->assertEqualValue(array($s1, $d2, $d3), $handlerBase);
|
||||
$this->assertEqual('or', $handlerBase->operator);
|
||||
|
||||
$handlerBase = HandlerBase::breakString("$s1 $d2++$d3");
|
||||
$this->assertEqualValue(array($s1, $d2, $d3), $handlerBase);
|
||||
$this->assertEqual('or', $handlerBase->operator);
|
||||
|
||||
// Test "and"s.
|
||||
$handlerBase = HandlerBase::breakString("$s1,$d2,$d3");
|
||||
$this->assertEqualValue(array($s1, $d2, $d3), $handlerBase);
|
||||
$this->assertEqual('and', $handlerBase->operator);
|
||||
|
||||
$handlerBase = HandlerBase::breakString("$s1,,$d2,$d3");
|
||||
$this->assertEqualValue(array($s1, $d2, $d3), $handlerBase);
|
||||
$this->assertEqual('and', $handlerBase->operator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace Drupal\views\Tests\Plugin;
|
|||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
|
@ -21,6 +22,8 @@ use Drupal\views\Views;
|
|||
*/
|
||||
class DisplayEntityReferenceTest extends PluginTestBase {
|
||||
|
||||
use EntityReferenceTestTrait;
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
|
@ -42,6 +45,13 @@ class DisplayEntityReferenceTest extends PluginTestBase {
|
|||
*/
|
||||
protected $fieldName;
|
||||
|
||||
/**
|
||||
* The used entity reference field name in the test.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $entityRefFieldName;
|
||||
|
||||
/**
|
||||
* The field storage.
|
||||
*
|
||||
|
@ -80,6 +90,10 @@ class DisplayEntityReferenceTest extends PluginTestBase {
|
|||
]);
|
||||
$this->field->save();
|
||||
|
||||
// Add an entity reference field to reference the same base table.
|
||||
$this->entityRefFieldName = 'field_test_entity_ref_entity_ref';
|
||||
$this->createEntityReferenceField('entity_test', 'entity_test', $this->entityRefFieldName, NULL, 'entity_test');
|
||||
|
||||
// Create some entities to search. Add a common string to the name and
|
||||
// the text field in two entities so we can test that we can search in both.
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
|
@ -129,6 +143,59 @@ class DisplayEntityReferenceTest extends PluginTestBase {
|
|||
|
||||
// Test that we have searched in both fields.
|
||||
$this->assertEqual(count($view->result), 2, 'Search returned two rows');
|
||||
$view->destroy();
|
||||
|
||||
// Add a relationship and a field using that relationship.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_display_entity_reference/default/relationship', ['name[entity_test.user_id]' => TRUE], t('Add and configure relationships'));
|
||||
$this->drupalPostForm(NULL, [], t('Apply'));
|
||||
|
||||
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_display_entity_reference/default/field', ['name[users_field_data.uid]' => TRUE], t('Add and configure fields'));
|
||||
$this->drupalPostForm(NULL, [], t('Apply'));
|
||||
|
||||
// Add the new field to the search fields.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_display_entity_reference/entity_reference_1/style_options', ['style_options[search_fields][uid]' => 'uid'], t('Apply'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
// Test that the search still works with the ralated field.
|
||||
$view = Views::getView('test_display_entity_reference');
|
||||
$view->setDisplay('entity_reference_1');
|
||||
|
||||
// Add the required settings to test a search operation.
|
||||
$options = [
|
||||
'match' => '2',
|
||||
'match_operator' => 'CONTAINS',
|
||||
'limit' => 0,
|
||||
'ids' => NULL,
|
||||
];
|
||||
$view->display_handler->setOption('entity_reference_options', $options);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
// Run validation when using a relationship to the same base table.
|
||||
$this->assertEqual(count($view->result), 2, 'Search returned two rows');
|
||||
$view->destroy();
|
||||
|
||||
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_display_entity_reference/default/relationship', ['name[entity_test__field_test_entity_ref_entity_ref.field_test_entity_ref_entity_ref]' => TRUE], t('Add and configure relationships'));
|
||||
$this->drupalPostForm(NULL, [], t('Apply'));
|
||||
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
// Test that the search still works with the related field.
|
||||
$view = Views::getView('test_display_entity_reference');
|
||||
$view->setDisplay('entity_reference_1');
|
||||
|
||||
// Add IDs to trigger validation.
|
||||
$options = [
|
||||
'match' => '1',
|
||||
'match_operator' => 'CONTAINS',
|
||||
'limit' => 0,
|
||||
'ids' => [1, 2],
|
||||
];
|
||||
$view->display_handler->setOption('entity_reference_options', $options);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
$this->assertEqual(count($view->result), 2, 'Search returned two rows');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class StyleSummaryTest extends ViewTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['entity_test'];
|
||||
public static $modules = ['entity_test', 'views_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -48,6 +48,9 @@ class StyleSummaryTest extends ViewTestBase {
|
|||
$entity->save();
|
||||
}
|
||||
}
|
||||
|
||||
$views_user = $this->drupalCreateUser(['administer views']);
|
||||
$this->drupalLogin($views_user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,6 +75,71 @@ class StyleSummaryTest extends ViewTestBase {
|
|||
$this->clickLink('type1');
|
||||
$entries = $this->cssSelect('div.view-content div.views-row');
|
||||
$this->assertEqual(2, count($entries));
|
||||
|
||||
// Add a base path to the summary settings.
|
||||
$edit = [
|
||||
'options[summary][options][default_summary][base_path]' => 'test-summary',
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_summary/page_1/argument/type', $edit, t('Apply'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
// Test that the links still work.
|
||||
$this->drupalGet('test-summary');
|
||||
$this->clickLink('type1');
|
||||
$entries = $this->cssSelect('div.view-content div.views-row');
|
||||
$this->assertEqual(2, count($entries));
|
||||
|
||||
// Change the summary display to an unformatted list displaying 3 items.
|
||||
$edit = [
|
||||
'options[summary][format]' => 'unformatted_summary',
|
||||
'options[summary][options][unformatted_summary][override]' => '1',
|
||||
'options[summary][options][unformatted_summary][items_per_page]' => '3',
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_summary/page_1/argument/type', $edit, t('Apply'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_summary/page_1/argument/type');
|
||||
$this->drupalGet('test-summary');
|
||||
|
||||
$summary_list = $this->cssSelect('.views-summary-unformatted');
|
||||
$this->assertEqual(3, count($summary_list));
|
||||
|
||||
foreach ($summary_list as $summary_list_item) {
|
||||
$this->assertEqual('(5)', trim((string) $summary_list_item));
|
||||
}
|
||||
|
||||
$summary_links = $this->cssSelect('.views-summary-unformatted a');
|
||||
$this->assertEqual(3, count($summary_links));
|
||||
foreach ($summary_links as $index => $summary_link) {
|
||||
$this->assertEqual('type' . $index, trim((string) $summary_link));
|
||||
}
|
||||
|
||||
$this->clickLink('type1');
|
||||
$entries = $this->cssSelect('div.view-content div.views-row');
|
||||
$this->assertEqual(2, count($entries));
|
||||
|
||||
// Add a base path to the summary settings.
|
||||
$edit = [
|
||||
'options[summary][options][unformatted_summary][base_path]' => 'test-summary',
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_summary/page_1/argument/type', $edit, t('Apply'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
// Test that the links still work.
|
||||
$this->drupalGet('test-summary');
|
||||
$this->clickLink('type1');
|
||||
$entries = $this->cssSelect('div.view-content div.views-row');
|
||||
$this->assertEqual(2, count($entries));
|
||||
|
||||
// Set base_path to an unknown path and test that the links lead to the
|
||||
// front page.
|
||||
$edit = [
|
||||
'options[summary][options][unformatted_summary][base_path]' => 'unknown-path',
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_summary/page_1/argument/type', $edit, t('Apply'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
$this->drupalGet('test-summary');
|
||||
$this->assertLinkByHref('/');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ display:
|
|||
specify_validation: true
|
||||
plugin_id: string
|
||||
entity_type: entity_test
|
||||
admin_label: type
|
||||
fields:
|
||||
id:
|
||||
id: id
|
||||
|
|
|
@ -277,11 +277,29 @@ function template_preprocess_views_view_summary(&$variables) {
|
|||
|
||||
if (!empty($argument->options['summary_options']['base_path'])) {
|
||||
$base_path = $argument->options['summary_options']['base_path'];
|
||||
$tokens = $this->getArgumentsTokens();
|
||||
$base_path = $this->viewsTokenReplace($base_path, $tokens);
|
||||
$tokens = $view->getDisplay()->getArgumentsTokens();
|
||||
$base_path = $argument->globalTokenReplace($base_path, $tokens);
|
||||
// @todo Views should expect and store a leading /. See:
|
||||
// https://www.drupal.org/node/2423913
|
||||
$url = Url::fromUserInput('/' . $base_path);
|
||||
try {
|
||||
/** @var \Symfony\Component\Routing\Route $route */
|
||||
$route_name = $url->getRouteName();
|
||||
$route = \Drupal::service('router.route_provider')->getRouteByName($route_name);
|
||||
|
||||
$route_variables = $route->compile()->getVariables();
|
||||
$parameters = $url->getRouteParameters();
|
||||
|
||||
foreach ($route_variables as $variable_name) {
|
||||
$parameters[$variable_name] = array_shift($args);
|
||||
}
|
||||
|
||||
$url->setRouteParameters($parameters);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
// If the given route doesn't exist, default to <front>
|
||||
$url = Url::fromRoute('<front>');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$url = $view->getUrl($args)->setOptions($url_options);
|
||||
|
@ -307,6 +325,7 @@ function template_preprocess_views_view_summary(&$variables) {
|
|||
* visually distinct.
|
||||
*/
|
||||
function template_preprocess_views_view_summary_unformatted(&$variables) {
|
||||
/** @var \Drupal\views\ViewExecutable $view */
|
||||
$view = $variables['view'];
|
||||
$argument = $view->argument[$view->build_info['summary_level']];
|
||||
|
||||
|
@ -346,11 +365,27 @@ function template_preprocess_views_view_summary_unformatted(&$variables) {
|
|||
|
||||
if (!empty($argument->options['summary_options']['base_path'])) {
|
||||
$base_path = $argument->options['summary_options']['base_path'];
|
||||
$tokens = $this->getArgumentsTokens();
|
||||
$base_path = $this->viewsTokenReplace($base_path, $tokens);
|
||||
$tokens = $view->getDisplay()->getArgumentsTokens();
|
||||
$base_path = $argument->globalTokenReplace($base_path, $tokens);
|
||||
// @todo Views should expect and store a leading /. See:
|
||||
// https://www.drupal.org/node/2423913
|
||||
$url = Url::fromUserInput('/' . $base_path);
|
||||
try {
|
||||
/** @var \Symfony\Component\Routing\Route $route */
|
||||
$route = \Drupal::service('router.route_provider')->getRouteByName($url->getRouteName());
|
||||
$route_variables = $route->compile()->getVariables();
|
||||
$parameters = $url->getRouteParameters();
|
||||
|
||||
foreach ($route_variables as $variable_name) {
|
||||
$parameters[$variable_name] = array_shift($args);
|
||||
}
|
||||
|
||||
$url->setRouteParameters($parameters);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
// If the given route doesn't exist, default to <front>
|
||||
$url = Url::fromRoute('<front>');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$url = $view->getUrl($args)->setOptions($url_options);
|
||||
|
|
Reference in a new issue