EntityTypeInterface::getGroup() has the following short description.

Gets the machine name of the entity type group.

AFAICT, we don't anywhere explain what an entity type group actually is.

The documentation page should say that, in core, the group will either be content or config.

Issue fork drupal-3107500

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joachim created an issue. See original summary.

longwave’s picture

Is this useful? Should we deprecate this? It doesn't seem to be used anywhere in core:

$ egrep -r 'getGroup\(' core
core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php:    $this->assertEquals($group_name, $this->contextualLinkDefault->getGroup());
core/modules/breakpoint/tests/src/Unit/BreakpointTest.php:    $this->assertEquals('Breakpoint', $this->breakpoint->getGroup());
core/modules/breakpoint/src/Breakpoint.php:  public function getGroup() {
core/modules/breakpoint/src/BreakpointInterface.php:  public function getGroup();
core/lib/Drupal/Core/Entity/EntityType.php:  public function getGroup() {
core/lib/Drupal/Core/Entity/EntityTypeInterface.php:  public function getGroup();
core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php:  public function getGroup() {
core/lib/Drupal/Core/Menu/ContextualLinkDefault.php:  public function getGroup() {
core/lib/Drupal/Core/Menu/ContextualLinkInterface.php:  public function getGroup();

In contextual links, breakpoints and execution contexts "group" means a different thing, so as far as I can see this isn't actually used anywhere; I think we perhaps are better off using interfaces to identify this sort of thing.

longwave’s picture

The same question was asked in #2549017-2: Add getGroup() and getGroupLabel() to an interface and add docs when it was first introduced.

Group *labels* are useful as per #2116551: Fix the UX of Entity Reference fields

joachim’s picture

> Is this useful? Should we deprecate this? It doesn't seem to be used anywhere in core:

Yes! Anytime you want to get all content entities or all config entities. And I think it's much more elegant than using the interfaces.

See #3107499: use EntityTypeInterface::getGroup() instead of reflection for example.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
larowlan’s picture

Issue tags: +Bug Smash Initiative

Adding some tags to shed some light on this good novice/first issue

joachim’s picture

This needs to say something like:

The entity type group is one of:

- content: Entities which form the content of a site, whose data changes frequently, typically extensible with custom fields and stored in the database.
- config: Entities which define structural elements of a site, which are managed as part of the site's configuration.

avpaderno’s picture

Title: EntityTypeInterface::getGroup() should explain what the group is » EntityTypeInterface::getGroup() doesn't explain what the group is
Version: 9.3.x-dev » 9.4.x-dev
Issue summary: View changes
avpaderno’s picture

group is the value passed in the annotation for that entity type, which means that the values set by Drupal core are only a restrict set of possible values. They can be given as example, but the documentation should not make users think those are the only possible values.

The following interface properties should also be better documented.

  /**
   * The machine name of the entity type group.
   *
   * @var string
   */
  protected $group;

  /**
   * The human-readable name of the entity type group.
   *
   * @var string|\Drupal\Core\StringTranslation\TranslatableMarkup
   *
   * @see \Drupal\Core\Entity\EntityTypeInterface::getGroupLabel()
   */
  protected $group_label;

At least, the first property should contain a reference to the interface method, if its documentation is going to explain what an entity type group is.

  /**
   * The machine name of the entity type group.
   *
   * @var string
   *
   * @see \Drupal\Core\Entity\EntityTypeInterface::getGroup()
   */
  protected $group;

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

joachim’s picture

Status: Active » Needs review
smustgrave’s picture

Rerunning tests. Though I'm 99% they were random failures.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Yup random failures.

Reviewed the changes and now understand what entity groups are! haha

quietone’s picture

Status: Reviewed & tested by the community » Needs work
joachim’s picture

Status: Needs work » Needs review

Fixed, and rebased.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Looks great to me now.

quietone’s picture

Status: Reviewed & tested by the community » Needs work

Good to see this being documented. I made a thorough read this time and have made some suggestion and I have some questions.

quietone’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Novice

I re-read the changes and I think they are clear, correct and follow our standards. Back to RTBC

alexpott’s picture

Version: 10.1.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 817c02e84c to 10.1.x and 903768e429 to 10.0.x and 46f4d42d9a to 9.5.x. Thanks!

As a documentation improvement I backported this to 9.5.x

  • alexpott committed 817c02e8 on 10.1.x
    Issue #3107500 by joachim, quietone, longwave, apaderno:...

  • alexpott committed 903768e4 on 10.0.x
    Issue #3107500 by joachim, quietone, longwave, apaderno:...

  • alexpott committed 46f4d42d on 9.5.x
    Issue #3107500 by joachim, quietone, longwave, apaderno:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.