function Item::baseFieldDefinitions

Same name in other branches
  1. 9 core/modules/aggregator/src/Entity/Item.php \Drupal\aggregator\Entity\Item::baseFieldDefinitions()

Overrides ContentEntityBase::baseFieldDefinitions

File

core/modules/aggregator/src/Entity/Item.php, line 56

Class

Item
Defines the aggregator item entity class.

Namespace

Drupal\aggregator\Entity

Code

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    
    /** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['iid']->setLabel(t('Aggregator item ID'))
        ->setDescription(t('The ID of the feed item.'));
    $fields['langcode']->setLabel(t('Language code'))
        ->setDescription(t('The feed item language code.'));
    $fields['fid'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Source feed'))
        ->setRequired(TRUE)
        ->setDescription(t('The aggregator feed entity associated with this item.'))
        ->setSetting('target_type', 'aggregator_feed')
        ->setDisplayOptions('view', [
        'label' => 'hidden',
        'type' => 'entity_reference_label',
        'weight' => 0,
    ])
        ->setDisplayConfigurable('form', TRUE);
    $fields['title'] = BaseFieldDefinition::create('string')->setLabel(t('Title'))
        ->setDescription(t('The title of the feed item.'));
    $fields['link'] = BaseFieldDefinition::create('uri')->setLabel(t('Link'))
        ->setDescription(t('The link of the feed item.'))
        ->setDisplayOptions('view', [
        'region' => 'hidden',
    ])
        ->setDisplayConfigurable('view', TRUE);
    $fields['author'] = BaseFieldDefinition::create('string')->setLabel(t('Author'))
        ->setDescription(t('The author of the feed item.'))
        ->setDisplayOptions('view', [
        'label' => 'hidden',
        'weight' => 3,
    ])
        ->setDisplayConfigurable('view', TRUE);
    $fields['description'] = BaseFieldDefinition::create('string_long')->setLabel(t('Description'))
        ->setDescription(t('The body of the feed item.'));
    $fields['timestamp'] = BaseFieldDefinition::create('created')->setLabel(t('Posted on'))
        ->setDescription(t('Posted date of the feed item, as a Unix timestamp.'))
        ->setDisplayOptions('view', [
        'label' => 'hidden',
        'type' => 'timestamp_ago',
        'weight' => 1,
    ])
        ->setDisplayConfigurable('view', TRUE);
    // @todo Convert to a real UUID field in
    //   https://www.drupal.org/node/2149851.
    $fields['guid'] = BaseFieldDefinition::create('string_long')->setLabel(t('GUID'))
        ->setDescription(t('Unique identifier for the feed item.'));
    return $fields;
}

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