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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 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.