public function BatBookingHandlerNightField::render in Booking and Availability Management Tools for Drupal 8
Renders the field.
Parameters
\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.
Return value
string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
Overrides FieldPluginBase::render
File
- modules/
bat_booking/ src/ Plugin/ views/ field/ BatBookingHandlerNightField.php, line 22 - This field handler aggregates calendar edit links for a Bat Type under a single field.
Class
- BatBookingHandlerNightField
- Plugin annotation @ViewsField("bat_booking_handler_night_field");
Namespace
Drupal\bat_booking\Plugin\views\fieldCode
public function render(ResultRow $values) {
$booking = $this
->getEntity($values);
$start_date = new \DateTime($booking
->get('booking_start_date')
->getValue()[0]['value']);
$end_date = new \DateTime($booking
->get('booking_end_date')
->getValue()[0]['value']);
return $end_date
->diff($start_date)->days;
}