protected function CustomEntityField::getItemValue in CiviCRM Entity 8.3
Process each value depending on the set definition type.
Parameters
mixed $value: The value returned by CiviCRM API.
\Drupal\Core\FieldDefinitionInterface $definition: The field definition.
Return value
mixed The processed item value.
See also
\Drupal\civicrm_entity\CiviEntityStorage::initFieldValues()
1 call to CustomEntityField::getItemValue()
- CustomEntityField::createEntity in src/
Plugin/ views/ field/ CustomEntityField.php - Populate the entity from CiviCRM API.
File
- src/
Plugin/ views/ field/ CustomEntityField.php, line 280
Class
- CustomEntityField
- A field that displays entity field data for custom fields.
Namespace
Drupal\civicrm_entity\Plugin\views\fieldCode
protected function getItemValue($value, FieldDefinitionInterface $definition) {
if (is_null($value)) {
return NULL;
}
switch ($definition
->getType()) {
case 'datetime':
$datetime_format = $definition
->getSetting('datetime_type') === DateTimeItem::DATETIME_TYPE_DATE ? DateTimeItemInterface::DATE_STORAGE_FORMAT : DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
return (new \DateTime($value, new \DateTimeZone(date_default_timezone_get())))
->setTimezone(new \DateTimeZone('UTC'))
->format($datetime_format);
}
return $value;
}