Allows bundle classes to be configured using attributes. This removes the need to implement hook_entity_bundle_info_alter().

Bundle class attributes are now in core. Since 11.4.0 Entity bundle classes can be defined and discovered using the Drupal\Core\Entity\Attribute\Bundle attribute. Existing sites using this module will continue to work, new sites should use functionality from Drupal core. It should be possible to migrate to the core attribute simply by swapping the namespace in your use statements.

Example

<?php
namespace Drupal\my_module\Entity\Node;
use Drupal\bca\Attribute\Bundle;
use Drupal\Core\StringTranslation\TranslatableMarkup;
#[Bundle(
 entityType: 'node',
 bundle: 'article',
 label: new TranslatableMarkup('Article'),
)]
class Article extends Node { }

Annotations

Prior to BCA 1.1.0 and Drupal 10.2.0 it is necessary to use annotations instead of attributes. The 1.1.x branch of this module supports using either annotations or attributes, while the 2.x branch supports only attributes. See the 1.1.x README for more details and examples.

Supporting organizations:

Project information

Releases

1.1.1 Stable release covered by the Drupal Security Team released 4 June 2024
Works with Drupal: ^10.2 || ^11

Drupal 11 support

Install:

Development version: 1.1.x-dev updated 3 Jun 2024 at 23:54 UTC

Development version: 2.0.x-dev updated 25 Jun 2026 at 22:42 UTC

Using Composer to manage Drupal site dependencies