public function EntityTypeInfo::entityBundleFieldInfoAlter in Workbench Moderation 8
Same name and namespace in other branches
- 8.2 src/EntityTypeInfo.php \Drupal\workbench_moderation\EntityTypeInfo::entityBundleFieldInfoAlter()
Force moderatable bundles to have a moderation_state field.
Parameters
\Drupal\Core\Field\FieldDefinitionInterface[] $fields: The array of bundle field definitions.
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.
string $bundle: The bundle.
See also
hook_entity_bundle_field_info_alter();
File
- src/
EntityTypeInfo.php, line 306
Class
- EntityTypeInfo
- Service class for manipulating entity type information.
Namespace
Drupal\workbench_moderationCode
public function entityBundleFieldInfoAlter(array &$fields, EntityTypeInterface $entity_type, $bundle) {
if ($this->moderationInfo
->isModeratableBundle($entity_type, $bundle) && !empty($fields['moderation_state'])) {
$fields['moderation_state']
->addConstraint('ModerationState', []);
}
}