function publication_date_entity_base_field_info in Publication Date 8.2
Same name and namespace in other branches
- 8 publication_date.module \publication_date_entity_base_field_info()
Implements hook_entity_base_field_info().
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type:
Return value
array
File
- ./
publication_date.module, line 29 - Add a field to nodes containing the publication date.
Code
function publication_date_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = [];
if ($entity_type
->id() == 'node') {
$fields['published_at'] = BaseFieldDefinition::create('published_at')
->setLabel(t('Published on'))
->setDescription(t('Keep the publication timestamp for each node.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'region' => 'hidden',
))
->setDisplayConfigurable('view', TRUE)
->setDisplayOptions('form', array(
'type' => 'publication_date_timestamp',
'weight' => 10,
))
->setDisplayConfigurable('form', TRUE);
}
return $fields;
}