public static function BrightcovePlayer::baseFieldDefinitions in Brightcove Video Connect 8
Same name and namespace in other branches
- 8.2 src/Entity/BrightcovePlayer.php \Drupal\brightcove\Entity\BrightcovePlayer::baseFieldDefinitions()
- 3.x src/Entity/BrightcovePlayer.php \Drupal\brightcove\Entity\BrightcovePlayer::baseFieldDefinitions()
Provides base field definitions for an entity type.
Implementations typically use the class \Drupal\Core\Field\BaseFieldDefinition for creating the field definitions; for example a 'name' field could be defined as the following:
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'));
By definition, base fields are fields that exist for every bundle. To provide definitions for fields that should only exist on some bundles, use \Drupal\Core\Entity\FieldableEntityInterface::bundleFieldDefinitions().
The definitions returned by this function can be overridden for all bundles by hook_entity_base_field_info_alter() or overridden on a per-bundle basis via 'base_field_override' configuration entities.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition. Useful when a single class is used for multiple, possibly dynamic entity types.
Return value
\Drupal\Core\Field\FieldDefinitionInterface[] An array of base field definitions for the entity type, keyed by field name.
Overrides ContentEntityBase::baseFieldDefinitions
See also
\Drupal\Core\Entity\EntityFieldManagerInterface::getFieldDefinitions()
\Drupal\Core\Entity\FieldableEntityInterface::bundleFieldDefinitions()
File
- src/
Entity/ BrightcovePlayer.php, line 92
Class
- BrightcovePlayer
- Defines the Brightcove Player.
Namespace
Drupal\brightcove\EntityCode
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['bcpid'] = BaseFieldDefinition::create('integer')
->setLabel(t('ID'))
->setDescription(t('The Drupal entity ID of the Brightcove Player.'))
->setReadOnly(TRUE);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The Brightcove Player UUID.'))
->setReadOnly(TRUE);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Player name'))
->setDescription(t('The name of the Brightcove Player.'));
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language code'))
->setDescription(t('The language code for the Brightcove Player.'));
$fields['api_client'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('API Client'))
->setDescription(t('API Client to use for the Player.'))
->setRequired(TRUE)
->setSetting('target_type', 'brightcove_api_client');
$fields['uid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setDescription(t('The username of the Brightcove Playlist author.'))
->setSetting('target_type', 'user')
->setDefaultValueCallback('Drupal\\brightcove\\Entity\\BrightcovePlayer::getCurrentUserId')
->setTranslatable(TRUE);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the Brightcove Player was created.'))
->setTranslatable(TRUE);
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the Brightcove Player was last edited.'))
->setTranslatable(TRUE);
$fields['player_id'] = BaseFieldDefinition::create('string')
->setLabel(t('Player ID'))
->setDescription(t('Unique Player ID assigned by Brightcove.'))
->setReadOnly(TRUE);
$fields['adjusted'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Adjusted'))
->setDescription(t('Indicates if player dimensions should be adjusted for playlist.'));
$fields['height'] = BaseFieldDefinition::create('float')
->setLabel(t('Adjusted'))
->setDescription(t('The height of the player.'));
$fields['width'] = BaseFieldDefinition::create('float')
->setLabel(t('Adjusted'))
->setDescription(t('The width of the player.'));
return $fields;
}