function Feed::baseFieldDefinitions
Same name in other branches
- 8.9.x core/modules/aggregator/src/Entity/Feed.php \Drupal\aggregator\Entity\Feed::baseFieldDefinitions()
Overrides ContentEntityBase::baseFieldDefinitions
File
-
core/
modules/ aggregator/ src/ Entity/ Feed.php, line 138
Class
- Feed
- Defines the aggregator feed entity class.
Namespace
Drupal\aggregator\EntityCode
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['fid']->setLabel(t('Feed ID'))
->setDescription(t('The ID of the aggregator feed.'));
$fields['uuid']->setDescription(t('The aggregator feed UUID.'));
$fields['langcode']->setLabel(t('Language code'))
->setDescription(t('The feed language code.'));
$fields['title'] = BaseFieldDefinition::create('string')->setLabel(t('Title'))
->setDescription(t('The name of the feed (or the name of the website providing the feed).'))
->setRequired(TRUE)
->setSetting('max_length', 255)
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -5,
])
->setDisplayConfigurable('form', TRUE)
->addConstraint('FeedTitle');
$fields['url'] = BaseFieldDefinition::create('uri')->setLabel(t('URL'))
->setDescription(t('The fully-qualified URL of the feed.'))
->setRequired(TRUE)
->setDisplayOptions('form', [
'type' => 'uri',
'weight' => -3,
])
->setDisplayConfigurable('form', TRUE)
->addConstraint('FeedUrl');
$intervals = [
900,
1800,
3600,
7200,
10800,
21600,
32400,
43200,
64800,
86400,
172800,
259200,
604800,
1209600,
2419200,
];
$period = array_map([
\Drupal::service('date.formatter'),
'formatInterval',
], array_combine($intervals, $intervals));
$period[FeedStorageInterface::CLEAR_NEVER] = t('Never');
$fields['refresh'] = BaseFieldDefinition::create('list_integer')->setLabel(t('Update interval'))
->setDescription(t('The length of time between feed updates. Requires a correctly configured cron maintenance task.'))
->setDefaultValue(3600)
->setSetting('unsigned', TRUE)
->setRequired(TRUE)
->setSetting('allowed_values', $period)
->setDisplayOptions('form', [
'type' => 'options_select',
'weight' => -2,
])
->setDisplayConfigurable('form', TRUE);
$fields['checked'] = BaseFieldDefinition::create('timestamp')->setLabel(t('Checked', [], [
'context' => 'Examined',
]))
->setDescription(t('Last time feed was checked for new items, as Unix timestamp.'))
->setDefaultValue(0)
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'timestamp_ago',
'weight' => 1,
])
->setDisplayConfigurable('view', TRUE);
$fields['queued'] = BaseFieldDefinition::create('timestamp')->setLabel(t('Queued'))
->setDescription(t('Time when this feed was queued for refresh, 0 if not queued.'))
->setDefaultValue(0);
$fields['link'] = BaseFieldDefinition::create('uri')->setLabel(t('URL'))
->setDescription(t('The link of the feed.'))
->setDisplayOptions('view', [
'label' => 'inline',
'weight' => 4,
])
->setDisplayConfigurable('view', TRUE);
$fields['description'] = BaseFieldDefinition::create('string_long')->setLabel(t('Description'))
->setDescription(t("The parent website's description that comes from the @description element in the feed.", [
'@description' => '<description>',
]));
$fields['image'] = BaseFieldDefinition::create('uri')->setLabel(t('Image'))
->setDescription(t('An image representing the feed.'));
$fields['hash'] = BaseFieldDefinition::create('string')->setLabel(t('Hash'))
->setSetting('is_ascii', TRUE)
->setDescription(t('Calculated hash of the feed data, used for validating cache.'));
$fields['etag'] = BaseFieldDefinition::create('string')->setLabel(t('Etag'))
->setDescription(t('Entity tag HTTP response header, used for validating cache.'));
// This is updated by the fetcher and not when the feed is saved, therefore
// it's a timestamp and not a changed field.
$fields['modified'] = BaseFieldDefinition::create('timestamp')->setLabel(t('Modified'))
->setDescription(t('When the feed was last modified, as a Unix timestamp.'));
return $fields;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.