You are here

function private_content_entity_base_field_info in Private content 8.2

Implements hook_entity_base_field_info().

File

./private_content.module, line 38
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('private')
      ->setLabel(t('Private'))
      ->setName('private')
      ->setRevisionable(TRUE)
      ->setDescription(t('When checked, only users with proper access permissions will be able to see this post.'))
      ->setDisplayOptions('view', [
      'weight' => 1,
    ])
      ->setDisplayOptions('form', [
      'weight' => 1,
    ])
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE);
  }
  return $fields;
}