function private_content_entity_base_field_info in Private 8.2
Same name and namespace in other branches
- 8 private_content.module \private_content_entity_base_field_info()
Implements hook_entity_base_field_info().
File
- ./
private_content.module, line 68 - A tremendously simple access control module -- it allows users to mark individual nodes as private; users with 'access private content' perms can read these nodes, while others cannot.
Code
function private_content_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = array();
if ($entity_type
->id() === 'node') {
$fields['private'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Private'))
->setName('private')
->setRevisionable(TRUE)
->setDescription(t('When checked, only users with proper access permissions will be able to see this post.'))
->setDefaultValueCallback('private_content_get_default')
->setDisplayOptions('view', [
'weight' => 1,
])
->setDisplayOptions('form', [
'weight' => 1,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
}
return $fields;
}