feat: implement mutability cutoff for rentals
addresses #869cca42x
This commit is contained in:
@@ -38,6 +38,7 @@ class AppExtension extends AbstractExtension
|
||||
new TwigFunction('qa_attribute', [AppRuntime::class, 'renderQaAttribute'], ['is_safe' => ['html']]),
|
||||
new TwigFunction('is_static_text', [AppRuntime::class, 'isStaticText']),
|
||||
new TwigFunction('is_hidden', [AppRuntime::class, 'isHidden']),
|
||||
new TwigFunction('is_travel_start_cutoff_reached', [AppRuntime::class, 'isTravelStartCutoffReached']),
|
||||
new TwigFunction('collect_invalid_field_labels', [AppRuntime::class, 'collectInvalidFieldLabels']),
|
||||
new TwigFunction('booking_theme', [AppRuntime::class, 'getBookingTheme']),
|
||||
new TwigFunction('gtm_id', [AppRuntime::class, 'getGtmId']),
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Twig;
|
||||
use App\BusProNet\DataProvider\CountryDataProvider;
|
||||
use App\EventListener\DomainThemeListener;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Condition\TravelStartCutoffReachedCondition;
|
||||
use App\Form\Service\CreateFieldStateProvider;
|
||||
use App\Form\Service\EditFieldStateProvider;
|
||||
use App\Model\DomainConfig;
|
||||
@@ -232,6 +233,23 @@ class AppRuntime implements RuntimeExtensionInterface
|
||||
return $labels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a travel start cutoff window has been reached.
|
||||
*
|
||||
* Uses inclusive day semantics: cutoff is reached when current day is on or
|
||||
* after (travel start day - $daysBeforeStart).
|
||||
*/
|
||||
public function isTravelStartCutoffReached(BookingDto $bookingDto, int $daysBeforeStart = 4): bool
|
||||
{
|
||||
try {
|
||||
$condition = new TravelStartCutoffReachedCondition($daysBeforeStart);
|
||||
} catch (\InvalidArgumentException) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $condition->evaluate($bookingDto, 0, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current booking theme from request attribute.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user