You are here

class DateParamConverter in Booking and Availability Management Tools for Drupal 8

Hierarchy

Expanded class hierarchy of DateParamConverter

1 string reference to 'DateParamConverter'
bat.services.yml in ./bat.services.yml
bat.services.yml
1 service uses DateParamConverter
bat_date in ./bat.services.yml
Drupal\bat\ParamConverter\DateParamConverter

File

src/ParamConverter/DateParamConverter.php, line 17
Contains \Drupal\bat\ParamConverter\DateParamConverter.

Namespace

Drupal\bat\ParamConverter
View 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

Namesort descending Modifiers Type Description Overrides
DateParamConverter::applies public function Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface::applies
DateParamConverter::convert public function Converts path variables to their corresponding objects. Overrides ParamConverterInterface::convert