localeSettings = $localeSettings; } /** * {@inheritdoc} */ public function getFilters() { return [ new TwigFilter('month_name', [$this, 'monthName']), new TwigFilter('date_short', [$this, 'dateShort']), new TwigFilter('date_time', [$this, 'dateTime']), ]; } /** * @param DateTime $date * @return string */ public function dateShort(DateTime $date) { $format = $this->localeSettings->getDateFormat(); return date_format($date, $format); } /** * @param DateTime $date * @return string */ public function dateTime(DateTime $date) { $format = $this->localeSettings->getDateTimeFormat(); return date_format($date, $format); } /** * @param \DateTime $date * @return string */ public function monthName(\DateTime $date) { return 'month.' . $date->format('n'); } }