public function DateParamConverter::convert in Booking and Availability Management Tools for Drupal 8
Converts path variables to their corresponding objects.
Parameters
mixed $value: The raw value.
mixed $definition: The parameter definition provided in the route options.
string $name: The name of the parameter.
array $defaults: The route defaults array.
Return value
mixed|null The converted parameter value.
Overrides ParamConverterInterface::convert
File
- src/
ParamConverter/ DateParamConverter.php, line 19 - Contains \Drupal\bat\ParamConverter\DateParamConverter.
Class
Namespace
Drupal\bat\ParamConverterCode
public function convert($value, $definition, $name, array $defaults) {
$date_string = Html::escape($value);
try {
$date = new \DateTime($date_string);
} catch (\Exception $e) {
$date = 0;
}
return $date;
}