Issue #3143316 by Lendude, sunset_bill, daffie, xjm, facine: "Getting the base fields is not supported for entity type" exception in ViewsConfigUpdater

merge-requests/2/head
Alex Pott 2020-06-22 11:37:55 +01:00
parent e3f32755a8
commit e685313296
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
6 changed files with 74 additions and 1 deletions

View File

@ -8,6 +8,7 @@ use Drupal\Core\Config\TypedConfigManagerInterface;
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;
@ -343,7 +344,7 @@ class ViewsConfigUpdater implements ContainerInjectionInterface {
$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);

View File

@ -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'

View File

@ -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 {
}

View File

@ -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';
}
}

View File

@ -0,0 +1,5 @@
name: 'views_config_entity_test'
description: 'Adds a Config Entity with views data'
type: module
package: Testing
version: VERSION

View File

@ -20,6 +20,11 @@ class ViewsConfigUpdaterTest extends ViewsKernelTestBase {
*/
protected $configUpdater;
/**
* {@inheritdoc}
*/
protected static $modules = ['views_config_entity_test'];
/**
* {@inheritdoc}
*/