You are here

public function DateRecurItem::getOccurrenceHandler in Recurring Dates Field 8

Get the occurrence handler and initialize it.

Return value

DateRecurOccurrenceHandlerInterface|bool

File

src/Plugin/Field/FieldType/DateRecurItem.php, line 174

Class

DateRecurItem
Plugin implementation of the 'date_recur' field type.

Namespace

Drupal\date_recur\Plugin\Field\FieldType

Code

public function getOccurrenceHandler() {
  if (empty($this->occurrenceHandler)) {
    $pluginName = $this
      ->getSetting('occurrence_handler_plugin');

    /** @var DateRecurOccurrenceHandlerManager $manager */
    $manager = \Drupal::getContainer()
      ->get('plugin.manager.date_recur_occurrence_handler');

    /** @var DateRecurOccurrenceHandlerInterface $occurrenceHandler */
    $this->occurrenceHandler = $manager
      ->createInstance($pluginName);
    $this->occurrenceHandler
      ->init($this);
  }
  return $this->occurrenceHandler;
}