You are here

function private_content_entity_base_field_info in Private 8

Same name and namespace in other branches
  1. 8.2 private_content.module \private_content_entity_base_field_info()

Implements hook_entity_base_field_info().

File

./private_content.module, line 60
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('Stores whether the node is marked private or not.'))
      ->setDefaultValue(FALSE)
      ->setDisplayConfigurable('view', TRUE);
  }
  return $fields;
}