Issue #3143316 by Lendude, sunset_bill, daffie, xjm, facine: "Getting the base fields is not supported for entity type" exception in ViewsConfigUpdater
parent
e3f32755a8
commit
e685313296
|
@ -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);
|
||||
|
|
|
@ -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'
|
|
@ -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 {
|
||||
}
|
|
@ -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';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
name: 'views_config_entity_test'
|
||||
description: 'Adds a Config Entity with views data'
|
||||
type: module
|
||||
package: Testing
|
||||
version: VERSION
|
|
@ -20,6 +20,11 @@ class ViewsConfigUpdaterTest extends ViewsKernelTestBase {
|
|||
*/
|
||||
protected $configUpdater;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = ['views_config_entity_test'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue