You are here

public static function DateRecurHelper::create in Recurring Dates Field 8.2

Same name and namespace in other branches
  1. 3.x src/DateRecurHelper.php \Drupal\date_recur\DateRecurHelper::create()
  2. 3.0.x src/DateRecurHelper.php \Drupal\date_recur\DateRecurHelper::create()
  3. 3.1.x src/DateRecurHelper.php \Drupal\date_recur\DateRecurHelper::create()

Create a instance of helper using system default.

Parameters

string $string: The repeat rule.

\DateTimeInterface $dtStart: The initial occurrence start date.

\DateTimeInterface|null $dtStartEnd: The initial occurrence end date, or NULL to use start date.

Return value

static A rule helper.

Throws

\Exception Throws various exceptions if string is invalid.

5 calls to DateRecurHelper::create()
DateRecurBasicWidget::validateRrule in src/Plugin/Field/FieldWidget/DateRecurBasicWidget.php
Validates RRULE and first occurrence dates.
DateRecurItem::getHelper in src/Plugin/Field/FieldType/DateRecurItem.php
Get the helper for this field item.
DateRecurRruleConstraintValidator::validate in src/Plugin/Validation/Constraint/DateRecurRruleConstraintValidator.php
Checks if the passed value is valid.
DateRecurRruleUnitTest::newRule in tests/src/Unit/DateRecurRruleUnitTest.php
Constructs a new DateRecurHelper object.
DateRecurRulePartConstraintValidator::validate in src/Plugin/Validation/Constraint/DateRecurRulePartConstraintValidator.php
Checks if the passed value is valid.

File

src/DateRecurHelper.php, line 55

Class

DateRecurHelper
Helper for recurring rules.

Namespace

Drupal\date_recur

Code

public static function create(string $string, \DateTimeInterface $dtStart, \DateTimeInterface $dtStartEnd = NULL) {

  // @todo: get the helper preference from Drupal module config.

  /** @var \Drupal\date_recur\DateRecurHelperInterface $dateRecurHelper */
  $dateRecurHelper = RlHelper::createInstance($string, $dtStart, $dtStartEnd);
  return new static($dateRecurHelper);
}