function nopremium_entity_base_field_info in Node Option Premium 8
Implements hook_entity_base_field_info().
File
- ./
nopremium.module, line 88 - Hook implementations.
Code
function nopremium_entity_base_field_info(EntityTypeInterface $entity_type) {
if ($entity_type
->id() === 'node') {
$fields = [];
$fields['premium'] = BaseFieldDefinition::create('boolean')
->setLabel(t('@label', [
'@label' => 'Premium content',
]))
->setDescription(t('@description', [
'@description' => 'Shows only the teasers of premium contents to unprivileged users.',
]))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDefaultValue(0)
->setDisplayConfigurable('form', TRUE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'settings' => [
'display_label' => TRUE,
],
'weight' => 16,
]);
return $fields;
}
}