Commit d0ced285 authored by Jess's avatar Jess
Browse files

Issue #3143316 by Lendude, sunset_bill, alexpott, daffie, xjm, facine:...

Issue #3143316 by Lendude, sunset_bill, alexpott, daffie, xjm, facine: "Getting the base fields is not supported for entity type" exception in ViewsConfigUpdater
parent f501138b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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);
+9 −0
Original line number Diff line number Diff line
views_config_entity_test.type.*:
  type: config_entity
  label: 'Config entity type with Views data'
  mapping:
    id:
      type: string
    name:
      type: label
      label: 'Name'
+26 −0
Original line number Diff line number Diff line
<?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 {
}
+27 −0
Original line number Diff line number Diff line
<?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';
  }

}
+5 −0
Original line number Diff line number Diff line
name: 'views_config_entity_test'
description: 'Adds a Config Entity with views data'
type: module
package: Testing
version: VERSION
Loading