You are here

public function ReportDateField::init in Commerce Reporting 8

Initialize the plugin.

Parameters

\Drupal\views\ViewExecutable $view: The view object.

\Drupal\views\Plugin\views\display\DisplayPluginBase $display: The display handler.

array $options: The options configured for this plugin.

Overrides EntityField::init

File

src/Plugin/views/field/ReportDateField.php, line 100

Class

ReportDateField
Plugin annotation @ViewsField("commerce_reports_report_date_field");

Namespace

Drupal\commerce_reports\Plugin\views\field

Code

public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
  parent::init($view, $display, $options);
  if (!empty($this->options['settings']['date_format'])) {
    $this->dateFormat = $this->options['settings']['date_format'];
    if ($this->dateFormat == 'custom') {
      $this->dateFormatString = $this->options['settings']['custom_date_format'];
    }
    else {

      /* @var \Drupal\Core\Datetime\DateFormatInterface $formatter */
      $formatter = $this->entityTypeManager
        ->getStorage('date_format')
        ->load($this->dateFormat);
      $this->dateFormatString = $formatter
        ->getPattern();
    }
  }
}