public static function OfficeHoursDatetime::get in Office Hours 8
Returns the data from a widget.
There are too many similar functions:
- OfficeHoursWidgetBase::massageFormValues();
- OfficeHoursItem, which requires an object;
- OfficeHoursDateTime::get() (this function).
@todo Use Core/TypedData/ComplexDataInterface.
Parameters
mixed $element: A string or array for time.
string $format: Required time format.
Return value
string Return value.
6 calls to OfficeHoursDatetime::get()
- OfficeHoursDatelist::valueCallback in src/
Element/ OfficeHoursDatelist.php - Callback for office_hours_select element.
- OfficeHoursDatetime::valueCallback in src/
Element/ OfficeHoursDatetime.php - Callback for office_hours_select element.
- OfficeHoursFormatterTrait::getRows in src/
OfficeHoursFormatterTrait.php - Returns the items of a field.
- OfficeHoursItemList::isOpen in src/
Plugin/ Field/ FieldType/ OfficeHoursItemList.php - Determines if the Entity is Open or Closed.
- OfficeHoursList::validateOfficeHoursSlot in src/
Element/ OfficeHoursList.php - Render API callback: Validates the element.
File
- src/
Element/ OfficeHoursDatetime.php, line 131
Class
- OfficeHoursDatetime
- Provides a one-line HTML5 time element.
Namespace
Drupal\office_hours\ElementCode
public static function get($element, $format = 'Hi') {
$value = '';
// Be prepared for Datetime and Numeric input.
// Numeric input set in validateOfficeHoursSlot().
if (!isset($element)) {
return $value;
}
if (isset($element['time'])) {
// Return NULL or time string.
$value = OfficeHoursDateHelper::format($element['time'], $format);
}
elseif (!empty($element['hour'])) {
$value = OfficeHoursDateHelper::format($element['hour'] * 100 + $element['minute'], $format);
}
elseif (!isset($element['hour'])) {
$value = OfficeHoursDateHelper::format($element, $format);
}
return $value;
}