class Rolling in Commerce Recurring Framework 8
Provides a rolling interval billing schedule.
Billing periods generated by this plugin always start at the beginning of the subscription. For example, if a monthly subscription is opened on Oct 12th, the generated billing period will be Oct 12th - Nov 12th.
Plugin annotation
@CommerceBillingSchedule(
id = "rolling",
label = @Translation("Rolling interval"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\commerce_recurring\Plugin\Commerce\BillingSchedule\BillingScheduleBase implements BillingScheduleInterface
- class \Drupal\commerce_recurring\Plugin\Commerce\BillingSchedule\IntervalBase
- class \Drupal\commerce_recurring\Plugin\Commerce\BillingSchedule\Rolling
- class \Drupal\commerce_recurring\Plugin\Commerce\BillingSchedule\IntervalBase
- class \Drupal\commerce_recurring\Plugin\Commerce\BillingSchedule\BillingScheduleBase implements BillingScheduleInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of Rolling
2 files declare their use of Rolling
- BillingScheduleTest.php in tests/
src/ Kernel/ Entity/ BillingScheduleTest.php - RollingTest.php in tests/
src/ Kernel/ Plugin/ Commerce/ BillingSchedule/ RollingTest.php
File
- src/
Plugin/ Commerce/ BillingSchedule/ Rolling.php, line 20
Namespace
Drupal\commerce_recurring\Plugin\Commerce\BillingScheduleView source
class Rolling extends IntervalBase {
/**
* {@inheritdoc}
*/
public function generateFirstBillingPeriod(DrupalDateTime $start_date) {
return new BillingPeriod($start_date, $this
->getInterval()
->add($start_date));
}
/**
* {@inheritdoc}
*/
public function generateNextBillingPeriod(DrupalDateTime $start_date, BillingPeriod $billing_period) {
$next_start_date = $billing_period
->getEndDate();
$next_end_date = $this
->getInterval()
->add($next_start_date);
// Retain the original billing day when possible.
// Jan 31st -> Feb 28th -> March 31st (not March 28th).
$billing_day = $start_date
->format('d');
if ($this
->getInterval()
->getUnit() == 'month' && $next_end_date
->format('d') != $billing_day) {
if ($billing_day <= $next_end_date
->format('t')) {
$next_end_date
->setDate($next_end_date
->format('Y'), $next_end_date
->format('m'), $billing_day);
}
}
return new BillingPeriod($next_start_date, $next_end_date);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BillingScheduleBase:: |
protected | property | The ID of the parent config entity. | |
BillingScheduleBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
BillingScheduleBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
BillingScheduleBase:: |
public | function |
Gets the billing schedule label. Overrides BillingScheduleInterface:: |
|
BillingScheduleBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
BillingScheduleBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
BillingScheduleBase:: |
public | function |
Constructs a new BillingScheduleBase object. Overrides PluginBase:: |
|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
IntervalBase:: |
public | function |
Checks whether the billing schedule allows trials. Overrides BillingScheduleInterface:: |
|
IntervalBase:: |
public | function |
Form constructor. Overrides BillingScheduleBase:: |
1 |
IntervalBase:: |
public | function |
Gets default configuration for this plugin. Overrides BillingScheduleBase:: |
1 |
IntervalBase:: |
public | function |
Generates the trial period. Overrides BillingScheduleInterface:: |
|
IntervalBase:: |
protected | function | Gets the current interval. | |
IntervalBase:: |
public | function |
Form submission handler. Overrides BillingScheduleBase:: |
1 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
Rolling:: |
public | function |
Generates the first billing period. Overrides BillingScheduleInterface:: |
|
Rolling:: |
public | function |
Generates the next billing period. Overrides BillingScheduleInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |