function Bundle::__construct

Same name in this branch
  1. 11.x core/modules/views/src/Plugin/views/filter/Bundle.php \Drupal\views\Plugin\views\filter\Bundle::__construct()
Same name and namespace in other branches
  1. 10 core/modules/views/src/Plugin/views/filter/Bundle.php \Drupal\views\Plugin\views\filter\Bundle::__construct()
  2. 9 core/modules/views/src/Plugin/views/filter/Bundle.php \Drupal\views\Plugin\views\filter\Bundle::__construct()
  3. 8.9.x core/modules/views/src/Plugin/views/filter/Bundle.php \Drupal\views\Plugin\views\filter\Bundle::__construct()
  4. main core/modules/views/src/Plugin/views/filter/Bundle.php \Drupal\views\Plugin\views\filter\Bundle::__construct()
  5. main core/lib/Drupal/Core/Entity/Attribute/Bundle.php \Drupal\Core\Entity\Attribute\Bundle::__construct()

Constructs a Bundle attribute object.

Parameters

string $entityType: The entity type ID.

string|null $bundle: The bundle ID, or NULL to use entity type ID as the bundle name.

\Drupal\Core\StringTranslation\TranslatableMarkup|null $label: (optional) The human-readable name of the bundle.

bool|null $translatable: (optional) A boolean value specifying whether this bundle has translation support enabled. If 'translatable' is defined for the bundle by an 'entity_bundle_info' hook, using NULL here will prevent that from being overridden. Otherwise, NULL is the same as FALSE.

Overrides ContentEntityType::__construct

File

core/lib/Drupal/Core/Entity/Attribute/Bundle.php, line 49

Class

Bundle
Defines an attribute for registering a bundle class.

Namespace

Drupal\Core\Entity\Attribute

Code

public function __construct(string $entityType, ?string $bundle = NULL, ?TranslatableMarkup $label = NULL, ?bool $translatable = NULL) {
  $bundle ??= $entityType;
  parent::__construct(id: "{$entityType}:{$bundle}", label: $label, additional: [
    'entity_type_bundle_info' => [
      $bundle => [
        // Setting this here because 'translatable' class property can not
        // be NULL.
'translatable' => $translatable,
      ],
    ],
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.