Skip to content

Commit

Permalink
Issue #3143316 by Lendude, sunset_bill, daffie, xjm, facine: "Getting…
Browse files Browse the repository at this point in the history
… the base fields is not supported for entity type" exception in ViewsConfigUpdater
  • Loading branch information
alexpott committed Jun 22, 2020
1 parent a39f8e7 commit 36d870b
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/views/src/ViewsConfigUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Entity\Sql\DefaultTableMapping;
use Symfony\Component\DependencyInjection\ContainerInterface;

Expand Down Expand Up @@ -285,7 +286,7 @@ protected function getMultivalueBaseFieldUpdateTableInfo() {
$table_info = [];

foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type->hasHandlerClass('views_data')) {
if ($entity_type->hasHandlerClass('views_data') && $entity_type->entityClassImplements(FieldableEntityInterface::class)) {
$base_field_definitions = $this->entityFieldManager->getBaseFieldDefinitions($entity_type_id);

$entity_storage = $this->entityTypeManager->getStorage($entity_type_id);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
views_config_entity_test.type.*:
type: config_entity
label: 'Config entity type with Views data'
mapping:
id:
type: string
name:
type: label
label: 'Name'
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Drupal\views_config_entity_test\Entity;

use Drupal\Core\Config\Entity\ConfigEntityBase;

/**
* Defines a configuration-based entity type used for testing Views data.
*
* @ConfigEntityType(
* id = "views_config_entity_test",
* label = @Translation("Test config entity type with Views data"),
* handlers = {
* "list_builder" = "Drupal\Core\Entity\EntityListBuilder",
* "views_data" = "Drupal\views_config_entity_test\ViewsConfigEntityTestViewsData"
* },
* admin_permission = "administer modules",
* config_prefix = "type",
* entity_keys = {
* "id" = "id",
* "label" = "name"
* }
* )
*/
class ViewsConfigEntityTest extends ConfigEntityBase {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Drupal\views_config_entity_test;

use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\views\EntityViewsDataInterface;

/**
* Provides a view to override views data for config test entity types.
*/
class ViewsConfigEntityTestViewsData implements EntityViewsDataInterface {

/**
* {@inheritdoc}
*/
public function getViewsData() {
return [];
}

/**
* @inheritDoc
*/
public function getViewsTableForEntityType(EntityTypeInterface $entity_type) {
return 'views_config_entity_test';
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: 'views_config_entity_test'
description: 'Adds a Config Entity with views data'
type: module
package: Testing
version: VERSION
5 changes: 5 additions & 0 deletions modules/views/tests/src/Kernel/ViewsConfigUpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class ViewsConfigUpdaterTest extends ViewsKernelTestBase {
*/
protected $configUpdater;

/**
* {@inheritdoc}
*/
protected static $modules = ['views_config_entity_test'];

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 36d870b

Please sign in to comment.