public EntityTypeInfo::entityBaseFieldInfo(EntityTypeInterface $entity_type)
Adds base field info to an entity type.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: Entity type for adding base fields to.
Return value
\Drupal\Core\Field\BaseFieldDefinition[] New fields added by moderation state.
File
- core/modules/content_moderation/src/EntityTypeInfo.php, line 288
Class
- EntityTypeInfo
- Manipulates entity type information.
Namespace
Drupal\content_moderation
Code
public function entityBaseFieldInfo(EntityTypeInterface $entity_type) {
if (!$this->moderationInfo->canModerateEntitiesOfEntityType($entity_type)) {
return [];
}
$fields = [];
$fields['moderation_state'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Moderation state'))
->setDescription(t('The moderation state of this piece of content.'))
->setComputed(TRUE)
->setClass(ModerationStateFieldItemList::class)
->setSetting('target_type', 'moderation_state')
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'hidden',
'weight' => -5,
])
->setDisplayOptions('form', [
'type' => 'moderation_state_default',
'weight' => 5,
'settings' => [],
])
->addConstraint('ModerationState', [])
->setDisplayConfigurable('form', FALSE)
->setDisplayConfigurable('view', FALSE)
->setTranslatable(TRUE);
return $fields;
}
Please login to continue.