drupal-console icon indicating copy to clipboard operation
drupal-console copied to clipboard

[generate:entity:content] misses revision annotations

Open stef-van-looveren opened this issue 3 years ago • 1 comments

Problem/Motivation

Drupal 9 expects content entities to have some annotations for revisions defined. A generated content entity with console leaves a InvalidDataTypeException after clearing cache.

How to reproduce

  • Drupal 9.0.7
  • Drupal console version 1.9.5

console output

  Enter the module name [admin_toolbar]:
  > subscription

  Enter the class of your new content entity [DefaultEntity]:
  > Log

  Enter the machine name of your new content entity [log]:
  >

  Enter the label of your new content entity [Log]:
  >

  Enter the base-path for the content entity routes [/admin/structure]:
  >

  Do you want this (content) entity to have bundles? (yes/no) [no]:
  > yes

  Is your entity translatable? (yes/no) [yes]:
  >

  Is your entity revisionable? (yes/no) [yes]:
  >

  Do you want this (content) entity to have forms? (yes/no) [yes]:
  >

  Do you want this (content) entity to have an owner? (yes/no) [yes]:
  >

  Do you want this entity to have "per bundle" permissions? (yes/no) [yes]:
  >


  // generate:entity:config

  Enter the base-path for the config entity routes [/admin/structure]:
  >

  Generated or updated files
Generation path: /var/www/html/web
  1 - modules/custom/subscription/subscription.permissions.yml
  2 - modules/custom/subscription/src/LogAccessControlHandler.php
  3 - modules/custom/subscription/src/LogTranslationHandler.php
  4 - modules/custom/subscription/src/Entity/LogInterface.php
  5 - modules/custom/subscription/src/Entity/Log.php
  6 - modules/custom/subscription/src/Entity/LogViewsData.php
  7 - modules/custom/subscription/src/LogListBuilder.php
  8 - modules/custom/subscription/src/LogHtmlRouteProvider.php
  9 - modules/custom/subscription/subscription.links.menu.yml
  10 - modules/custom/subscription/subscription.links.task.yml
  11 - modules/custom/subscription/subscription.links.action.yml
  12 - modules/custom/subscription/src/Form/LogSettingsForm.php
  13 - modules/custom/subscription/src/Form/LogForm.php
  14 - modules/custom/subscription/src/Form/LogDeleteForm.php
  15 - modules/custom/subscription/templates/log.html.twig
  16 - modules/custom/subscription/log.page.inc
  17 - modules/custom/subscription/src/Form/LogRevisionRevertTranslationForm.php
  18 - modules/custom/subscription/src/Form/LogRevisionDeleteForm.php
  19 - modules/custom/subscription/src/Form/LogRevisionRevertForm.php
  20 - modules/custom/subscription/src/Controller/LogController.php
  21 - modules/custom/subscription/src/LogStorage.php
  22 - modules/custom/subscription/src/LogStorageInterface.php
  23 - modules/custom/subscription/templates//log-content-add-list.html.twig
  24 - modules/custom/subscription/src/LogPermissions.php
  25 - modules/custom/subscription/subscription.module
  26 - modules/custom/subscription/subscription.module
  27 - modules/custom/subscription/subscription.module
  28 - modules/custom/subscription/config/schema/log_type.schema.yml
  29 - modules/custom/subscription/subscription.links.menu.yml
  30 - modules/custom/subscription/subscription.links.action.yml
  31 - modules/custom/subscription/src/Entity/LogTypeInterface.php
  32 - modules/custom/subscription/src/Entity/LogType.php
  33 - modules/custom/subscription/src/LogTypeHtmlRouteProvider.php
  34 - modules/custom/subscription/src/Form/LogTypeForm.php
  35 - modules/custom/subscription/src/Form/LogTypeDeleteForm.php
  36 - modules/custom/subscription/src/LogTypeListBuilder.php


Generated lines: 2129


  bash-5.0$ drush cr


In RevisionLogEntityTrait.php line 35:

  The entity type log does not have an "revision_created" entity revision metadata key.

Solution

Add this to the entities annotations to fix the error (modulename/src/Entity/entityname.php):

*   revision_metadata_keys = {
*     "revision_user" = "revision_user",
*     "revision_created" = "revision_created",
*     "revision_log_message" = "revision_log",
*   },

stef-van-looveren avatar Nov 16 '20 10:11 stef-van-looveren

Hi, the pull request by @stef-van-looveren works fine. Thank you.

finex avatar Sep 24 '21 07:09 finex