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

Generating content entities should extend EditorialContentEntityBase, not RevisionableContentEntityBase #199

Open
kevinquillen opened this issue Feb 26, 2025 · 0 comments

Comments

@kevinquillen
Copy link

Its a bit confusing core has both of these classes, but when generating content entities there is a slight nuance between the two. EditorialContentEntityBase seems better supported for both revisioning and moderation with its additional traits over the former.

abstract class EditorialContentEntityBase extends ContentEntityBase implements EntityChangedInterface, EntityPublishedInterface, RevisionLogInterface {

  use EntityChangedTrait;
  use EntityPublishedTrait;
  use RevisionLogEntityTrait;

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);

    // Add the revision metadata fields.
    $fields += static::revisionLogBaseFieldDefinitions($entity_type);

    // Add the published field.
    $fields += static::publishedBaseFieldDefinitions($entity_type);

    return $fields;
  }

}

The published field then allows Content Moderation to be used on the entity.

In addition, Entities should likely come with the following entity_keys:

    "owner" => "uid",
    "status" => "status",
    "published" => "status",
    'uid' => 'uid',

This would enable automatic support for Content Moderation in core for custom entities. If someone choses that they should be revisionable, this is probably what they are after. If they do not use Content Moderation, it looks like they get the same result right now and should not break anything (at a glance).

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

No branches or pull requests

1 participant