Loading src/Plugin/views/field/EventSeriesStartDate.php +18 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\recurring_events\Plugin\views\field; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Field handler to show the start date of an event series. Loading @@ -14,6 +15,22 @@ use Drupal\views\ResultRow; */ class EventSeriesStartDate extends FieldPluginBase { /** * The date formatter service. * * @var \Drupal\Core\Datetime\DateFormatterInterface */ protected $dateFormatter; /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); $instance->dateFormatter = $container->get('date.formatter'); return $instance; } /** * {@inheritdoc} */ Loading @@ -33,7 +50,7 @@ class EventSeriesStartDate extends FieldPluginBase { if (!empty($event_start)) { $format = \Drupal::config('recurring_events.eventseries.config')->get('date_format'); $start_date = $event_start->setTimezone($timezone)->format($format); $start_date = $this->dateFormatter->format($event_start->getTimestamp(), 'custom', $format, $timezone->getName()); } return $start_date; } Loading Loading
src/Plugin/views/field/EventSeriesStartDate.php +18 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\recurring_events\Plugin\views\field; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Field handler to show the start date of an event series. Loading @@ -14,6 +15,22 @@ use Drupal\views\ResultRow; */ class EventSeriesStartDate extends FieldPluginBase { /** * The date formatter service. * * @var \Drupal\Core\Datetime\DateFormatterInterface */ protected $dateFormatter; /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); $instance->dateFormatter = $container->get('date.formatter'); return $instance; } /** * {@inheritdoc} */ Loading @@ -33,7 +50,7 @@ class EventSeriesStartDate extends FieldPluginBase { if (!empty($event_start)) { $format = \Drupal::config('recurring_events.eventseries.config')->get('date_format'); $start_date = $event_start->setTimezone($timezone)->format($format); $start_date = $this->dateFormatter->format($event_start->getTimestamp(), 'custom', $format, $timezone->getName()); } return $start_date; } Loading