function EntityTypeInfo::entityBaseFieldInfo
Same name in this branch
- 9 core/modules/workspaces/src/EntityTypeInfo.php \Drupal\workspaces\EntityTypeInfo::entityBaseFieldInfo()
Same name in other branches
- 8.9.x core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::entityBaseFieldInfo()
- 8.9.x core/modules/workspaces/src/EntityTypeInfo.php \Drupal\workspaces\EntityTypeInfo::entityBaseFieldInfo()
- 10 core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::entityBaseFieldInfo()
- 10 core/modules/workspaces/src/EntityTypeInfo.php \Drupal\workspaces\EntityTypeInfo::entityBaseFieldInfo()
- 11.x core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::entityBaseFieldInfo()
- 11.x core/modules/workspaces/src/EntityTypeInfo.php \Drupal\workspaces\EntityTypeInfo::entityBaseFieldInfo()
- 11.x core/modules/workspaces/src/Hook/EntityTypeInfo.php \Drupal\workspaces\Hook\EntityTypeInfo::entityBaseFieldInfo()
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.
See also
File
-
core/
modules/ content_moderation/ src/ EntityTypeInfo.php, line 258
Class
- EntityTypeInfo
- Manipulates entity type information.
Namespace
Drupal\content_moderationCode
public function entityBaseFieldInfo(EntityTypeInterface $entity_type) {
if (!$this->moderationInfo
->isModeratedEntityType($entity_type)) {
return [];
}
$fields = [];
$fields['moderation_state'] = BaseFieldDefinition::create('string')->setLabel(t('Moderation state'))
->setDescription(t('The moderation state of this piece of content.'))
->setComputed(TRUE)
->setClass(ModerationStateFieldItemList::class)
->setDisplayOptions('view', [
'label' => 'hidden',
'region' => 'hidden',
'weight' => -5,
])
->setDisplayOptions('form', [
'type' => 'moderation_state_default',
'weight' => 100,
'settings' => [],
])
->addConstraint('ModerationState', [])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', FALSE)
->setReadOnly(FALSE)
->setTranslatable(TRUE);
return $fields;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.