updated core to 8.6.3
This commit is contained in:
@@ -53,9 +53,13 @@ function datetime_range_view_presave(ViewEntityInterface $view) {
|
||||
if (isset($display['display_options']['filters'])) {
|
||||
foreach ($display['display_options']['filters'] as $field_name => &$filter) {
|
||||
if ($filter['plugin_id'] === 'string') {
|
||||
$table_data = Views::viewsData()->get($filter['table']);
|
||||
if (!$table_data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get field config.
|
||||
$filter_views_data = Views::viewsData()->get($filter['table'])[$filter['field']]['filter'];
|
||||
$filter_views_data = $table_data[$filter['field']]['filter'];
|
||||
if (!isset($filter_views_data['entity_type']) || !isset($filter_views_data['field_name'])) {
|
||||
continue;
|
||||
}
|
||||
@@ -128,9 +132,13 @@ function datetime_range_view_presave(ViewEntityInterface $view) {
|
||||
if (isset($display['display_options']['sorts'])) {
|
||||
foreach ($display['display_options']['sorts'] as $field_name => &$sort) {
|
||||
if ($sort['plugin_id'] === 'standard') {
|
||||
$table_data = Views::viewsData()->get($sort['table']);
|
||||
if (!$table_data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get field config.
|
||||
$sort_views_data = Views::viewsData()->get($sort['table'])[$sort['field']]['sort'];
|
||||
$sort_views_data = $table_data[$sort['field']]['sort'];
|
||||
if (!isset($sort_views_data['entity_type']) || !isset($sort_views_data['field_name'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
name: 'Datetime range test'
|
||||
type: module
|
||||
description: 'Provides a testing module for datetime_range.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- drupal:taxonomy
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains datetime_range_test.module
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_entity_type_alter().
|
||||
*/
|
||||
function datetime_range_test_entity_type_alter(array &$entity_types) {
|
||||
// Inhibit views data for the 'taxonomy_term' entity type in order to cover
|
||||
// the case when an entity type provides no views data.
|
||||
// @see https://www.drupal.org/project/drupal/issues/2995578
|
||||
// @see \Drupal\Tests\datetime_range\Kernel\Views\EntityTypeWithoutViewsDataTest
|
||||
$entity_types['taxonomy_term']->setHandlerClass('views_data', NULL);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\datetime_range\Kernel\Views;
|
||||
|
||||
use Drupal\Core\Config\InstallStorage;
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\views\Entity\View;
|
||||
|
||||
/**
|
||||
* Tests datetime_range.module when an entity type provides no views data.
|
||||
*
|
||||
* @group datetime
|
||||
*/
|
||||
class EntityTypeWithoutViewsDataTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = [
|
||||
'datetime_range',
|
||||
'datetime_range_test',
|
||||
'node',
|
||||
'system',
|
||||
'taxonomy',
|
||||
'text',
|
||||
'user',
|
||||
'views',
|
||||
];
|
||||
|
||||
/**
|
||||
* Tests the case when an entity type provides no views data.
|
||||
*
|
||||
* @see datetime_test_entity_type_alter()
|
||||
* @see datetime_range_view_presave()
|
||||
*/
|
||||
public function testEntityTypeWithoutViewsData() {
|
||||
$view_yaml = drupal_get_path('module', 'taxonomy') . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY . '/views.view.taxonomy_term.yml';
|
||||
$values = Yaml::decode(file_get_contents($view_yaml));
|
||||
$this->assertEquals(SAVED_NEW, View::create($values)->save());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user