Unverified Commit 15e0b54c authored by alexpott's avatar alexpott

Issue #3143316 by Lendude, sunset_bill, daffie, xjm, facine: "Getting the base...

Issue #3143316 by Lendude, sunset_bill, daffie, xjm, facine: "Getting the base fields is not supported for entity type" exception in ViewsConfigUpdater
parent dbcb6ff6
......@@ -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;
......@@ -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);
......
views_config_entity_test.type.*:
type: config_entity
label: 'Config entity type with Views data'
mapping:
id:
type: string
name:
type: label
label: 'Name'
<?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 {
}
<?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';
}
}
name: 'views_config_entity_test'
description: 'Adds a Config Entity with views data'
type: module
package: Testing
version: VERSION
......@@ -19,6 +19,11 @@ class ViewsConfigUpdaterTest extends ViewsKernelTestBase {
*/
protected $configUpdater;
/**
* {@inheritdoc}
*/
protected static $modules = ['views_config_entity_test'];
/**
* {@inheritdoc}
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment