You are here

protected function Monthly::shouldReset in Commerce Core 8.2

Gets whether the sequence should be reset.

Parameters

\Drupal\commerce_number_pattern\Sequence $current_sequence: The current sequence.

Return value

bool TRUE if the sequence should be reset, FALSE otherwise.

Overrides SequentialNumberPatternBase::shouldReset

File

modules/number_pattern/src/Plugin/Commerce/NumberPattern/Monthly.php, line 30

Class

Monthly
Provides the monthly number pattern.

Namespace

Drupal\commerce_number_pattern\Plugin\Commerce\NumberPattern

Code

protected function shouldReset(Sequence $current_sequence) {

  // Reset the sequence if the current one is from a previous month.
  $generated_time = DrupalDateTime::createFromTimestamp($current_sequence
    ->getGeneratedTime());
  $current_time = DrupalDateTime::createFromTimestamp($this->time
    ->getCurrentTime());
  return $generated_time
    ->format('Y-m') != $current_time
    ->format('Y-m');
}