You are here

function og_entity_bundle_field_info in Organic groups 8

Implements hook_entity_bundle_field_info().

Add a read only property to group entities as a group flag.

File

./og.module, line 238

Code

function og_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
  if (!Og::isGroup($entity_type
    ->id(), $bundle)) {

    // Not a group type.
    return NULL;
  }
  $fields = [];
  $fields['og_group'] = BaseFieldDefinition::create('og_group')
    ->setLabel(new TranslatableMarkup('OG Group'))
    ->setComputed(TRUE)
    ->setTranslatable(FALSE)
    ->setDefaultValue(TRUE)
    ->setReadOnly(TRUE);
  return $fields;
}