protected function FieldDefinitionProvider::getIntegerDefinition in CiviCRM Entity 8.3
Gets an integer field definition.
If the field uses pseudo constants, it is turned into a list_integer and allowed values are set based on values that can be returned from the CiviCRM API, as they are references.
Parameters
array $civicrm_field: The CiviCRM field definition.
Return value
\Drupal\Core\Field\BaseFieldDefinition The base field definition.
1 call to FieldDefinitionProvider::getIntegerDefinition()
- FieldDefinitionProvider::getBaseFieldDefinition in src/
Entity/ FieldDefinitionProvider.php - Gets an entity base field definition from a CiviCRM field definition.
File
- src/
Entity/ FieldDefinitionProvider.php, line 147
Class
Namespace
Drupal\civicrm_entity\EntityCode
protected function getIntegerDefinition(array $civicrm_field) {
if (!empty($civicrm_field['pseudoconstant']) && $civicrm_field['name'] != 'card_type_id') {
$field = BaseFieldDefinition::create('list_integer')
->setSetting('allowed_values_function', 'civicrm_entity_pseudoconstant_options')
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'number_integer',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'options_select',
'weight' => 0,
]);
}
else {
$field = BaseFieldDefinition::create('integer')
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'number_integer',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'number',
'weight' => 0,
]);
}
return $field;
}