class DateParamConverter in Booking and Availability Management Tools for Drupal 8
Hierarchy
- class \Drupal\bat\ParamConverter\DateParamConverter implements ParamConverterInterface
Expanded class hierarchy of DateParamConverter
1 string reference to 'DateParamConverter'
1 service uses DateParamConverter
File
- src/
ParamConverter/ DateParamConverter.php, line 17 - Contains \Drupal\bat\ParamConverter\DateParamConverter.
Namespace
Drupal\bat\ParamConverterView source
class DateParamConverter implements ParamConverterInterface {
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;
}
public function applies($definition, $name, Route $route) {
return !empty($definition['type']) && $definition['type'] == 'bat_date';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DateParamConverter:: |
public | function |
Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface:: |
|
DateParamConverter:: |
public | function |
Converts path variables to their corresponding objects. Overrides ParamConverterInterface:: |