customer-riverside/web/modules/custom/riverside_pt/riverside_pt.module

36 lines
1.1 KiB
Text
Raw Normal View History

2026-05-13 13:55:52 -08:00
<?php
2026-05-13 14:26:33 -08:00
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Link;
use Drupal\Core\Routing\RouteMatchInterface;
function riverside_pt_system_breadcrumb_alter(Breadcrumb &$breadcrumb, RouteMatchInterface $route_match, array $context): void {
if ($route_match->getRouteName() === 'riverside_pt.booking') {
$breadcrumb = new Breadcrumb();
$breadcrumb->addLink(Link::createFromRoute('← Back', 'riverside_pt.schedule'));
$breadcrumb->addCacheContexts(['route']);
}
}
2026-05-13 13:55:52 -08:00
function riverside_pt_mail(string $key, array &$message, array $params): void {
if ($key !== 'booking_request') {
return;
}
$start = new \DateTime($params['start']);
$end = new \DateTime($params['end']);
$message['subject'] = 'Booking request — ' . $start->format('M j, Y g:i A');
2026-05-13 14:26:33 -08:00
$lines = [
2026-05-13 13:55:52 -08:00
'Name: ' . $params['first_name'] . ' ' . $params['last_name'],
'Phone: ' . $params['phone'],
'Slot: ' . $start->format('l, F j, Y') . ', ' . $start->format('g:i A') . '' . $end->format('g:i A'),
2026-05-13 14:26:33 -08:00
];
if (!empty($params['comments'])) {
$lines[] = 'Comments: ' . $params['comments'];
}
$message['body'][] = implode("\n", $lines);
2026-05-13 13:55:52 -08:00
}