function BlockContent::baseFieldDefinitions

Same name in other branches
  1. 9 core/modules/block_content/src/Entity/BlockContent.php \Drupal\block_content\Entity\BlockContent::baseFieldDefinitions()
  2. 8.9.x core/modules/block_content/src/Entity/BlockContent.php \Drupal\block_content\Entity\BlockContent::baseFieldDefinitions()
  3. 11.x core/modules/block_content/src/Entity/BlockContent.php \Drupal\block_content\Entity\BlockContent::baseFieldDefinitions()

Overrides EditorialContentEntityBase::baseFieldDefinitions

File

core/modules/block_content/src/Entity/BlockContent.php, line 191

Class

BlockContent
Defines the content block entity class.

Namespace

Drupal\block_content\Entity

Code

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    
    /** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['id']->setLabel(t('Content block ID'))
        ->setDescription(t('The content block ID.'));
    $fields['uuid']->setDescription(t('The content block UUID.'));
    $fields['revision_id']->setDescription(t('The revision ID.'));
    $fields['langcode']->setDescription(t('The content block language code.'));
    $fields['type']->setLabel(t('Block type'))
        ->setDescription(t('The block type.'));
    $fields['revision_log']->setDescription(t('The log entry explaining the changes in this revision.'));
    $fields['info'] = BaseFieldDefinition::create('string')->setLabel(t('Block description'))
        ->setDescription(t('A brief description of your block.'))
        ->setRevisionable(TRUE)
        ->setTranslatable(TRUE)
        ->setRequired(TRUE)
        ->setDisplayOptions('form', [
        'type' => 'string_textfield',
        'weight' => -5,
    ])
        ->setDisplayConfigurable('form', TRUE);
    $fields['changed'] = BaseFieldDefinition::create('changed')->setLabel(t('Changed'))
        ->setDescription(t('The time that the content block was last edited.'))
        ->setTranslatable(TRUE)
        ->setRevisionable(TRUE);
    $fields['reusable'] = BaseFieldDefinition::create('boolean')->setLabel(t('Reusable'))
        ->setDescription(t('A boolean indicating whether this block is reusable.'))
        ->setTranslatable(FALSE)
        ->setRevisionable(FALSE)
        ->setDefaultValue(TRUE);
    return $fields;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.