Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[generate:entity:content] misses revision annotations #4284

Closed
stef-van-looveren opened this issue Nov 16, 2020 · 1 comment · Fixed by #4285
Closed

[generate:entity:content] misses revision annotations #4284

stef-van-looveren opened this issue Nov 16, 2020 · 1 comment · Fixed by #4285

Comments

@stef-van-looveren
Copy link
Contributor

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",
*   },
@finex
Copy link

finex commented Sep 24, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants