public function UnitType::getEventDefaultValue in Booking and Availability Management Tools for Drupal 8
Parameters
$event_type:
File
- modules/
bat_unit/ src/ Entity/ UnitType.php, line 232 - Contains \Drupal\bat_unit\Entity\UnitType.
Class
- UnitType
- Defines the Unit type entity.
Namespace
Drupal\bat_unit\EntityCode
public function getEventDefaultValue($event_type) {
$langcode = $this->defaultLangcode;
if ($field = $this
->getEventValueDefaultField($event_type)) {
$field_info = FieldStorageConfig::loadByName('bat_unit_type', $field);
$values = $this
->getTranslation($langcode)
->get($field)
->getValue();
if (!empty($values)) {
if ($field_info
->getType() == 'entity_reference') {
return $values[0]['target_id'];
}
elseif ($field_info
->getType() == 'commerce_price') {
return $values[0]['number'];
}
elseif ($field_info
->getType() == 'text' || $field_info
->getType() == 'string' || $field_info
->getType() == 'number_integer') {
return $values[0]['value'];
}
}
else {
return FALSE;
}
}
}