public EntityTypeInfo::entityBundleFieldInfoAlter(&$fields, EntityTypeInterface $entity_type, $bundle)
Adds ModerationState constraint to bundles whose entities are moderated.
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
- core/modules/content_moderation/src/EntityTypeInfo.php, line 330
Class
- EntityTypeInfo
- Manipulates entity type information.
Namespace
Drupal\content_moderation
Code
1 2 3 4 5 | public function entityBundleFieldInfoAlter(& $fields , EntityTypeInterface $entity_type , $bundle ) { if (! empty ( $fields [ 'moderation_state' ]) && $this ->moderationInfo->shouldModerateEntitiesOfBundle( $entity_type , $bundle )) { $fields [ 'moderation_state' ]->addConstraint( 'ModerationState' , []); } } |
Please login to continue.