You are here

class Monthly in Commerce Core 8.2

Provides the monthly number pattern.

Plugin annotation


@CommerceNumberPattern(
  id = "monthly",
  label = @Translation("Monthly (Reset every month)"),
)

Hierarchy

Expanded class hierarchy of Monthly

File

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

Namespace

Drupal\commerce_number_pattern\Plugin\Commerce\NumberPattern
View source
class Monthly extends SequentialNumberPatternBase {

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'pattern' => '[pattern:year]-[pattern:month]-[pattern:number]',
    ] + parent::defaultConfiguration();
  }

  /**
   * {@inheritdoc}
   */
  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');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
Monthly::defaultConfiguration public function Gets default configuration for this plugin. Overrides SequentialNumberPatternBase::defaultConfiguration
Monthly::shouldReset protected function Gets whether the sequence should be reset. Overrides SequentialNumberPatternBase::shouldReset
NumberPatternBase::$parentEntity protected property The parent config entity.
NumberPatternBase::$token protected property The token service.
NumberPatternBase::getConfiguration public function Gets this plugin's configuration. Overrides ConfigurableInterface::getConfiguration
NumberPatternBase::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableInterface::setConfiguration
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
SequentialNumberPatternBase::$connection protected property The database connection.
SequentialNumberPatternBase::$entityTypeManager protected property The entity type manager.
SequentialNumberPatternBase::$lock protected property The lock backend.
SequentialNumberPatternBase::$time protected property The time.
SequentialNumberPatternBase::buildConfigurationForm public function Overrides NumberPatternBase::buildConfigurationForm
SequentialNumberPatternBase::create public static function Creates an instance of the plugin. Overrides NumberPatternBase::create
SequentialNumberPatternBase::generate public function Generates a number for the given content entity. Overrides NumberPatternBase::generate
SequentialNumberPatternBase::getCurrentSequence public function Gets the current sequence for the given entity. Overrides SequentialNumberPatternInterface::getCurrentSequence
SequentialNumberPatternBase::getInitialSequence public function Gets the initial sequence for the given entity. Overrides SequentialNumberPatternInterface::getInitialSequence
SequentialNumberPatternBase::getNextSequence public function Gets the next sequence for the given entity. Overrides SequentialNumberPatternInterface::getNextSequence
SequentialNumberPatternBase::getStoreId protected function Gets the store_id to use for the sequence.
SequentialNumberPatternBase::resetSequence public function Resets the sequence. Overrides SequentialNumberPatternInterface::resetSequence
SequentialNumberPatternBase::submitConfigurationForm public function Overrides NumberPatternBase::submitConfigurationForm
SequentialNumberPatternBase::validateConfigurationForm public function Overrides NumberPatternBase::validateConfigurationForm
SequentialNumberPatternBase::__construct public function Constructs a new SequentialNumberPatternBase object. Overrides NumberPatternBase::__construct
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.