You are here

public static function SmartDateRule::getMonthsLimit in Smart Date 3.0.x

Same name and namespace in other branches
  1. 3.1.x modules/smart_date_recur/src/Entity/SmartDateRule.php \Drupal\smart_date_recur\Entity\SmartDateRule::getMonthsLimit()
  2. 3.2.x modules/smart_date_recur/src/Entity/SmartDateRule.php \Drupal\smart_date_recur\Entity\SmartDateRule::getMonthsLimit()
  3. 3.3.x modules/smart_date_recur/src/Entity/SmartDateRule.php \Drupal\smart_date_recur\Entity\SmartDateRule::getMonthsLimit()
  4. 3.4.x modules/smart_date_recur/src/Entity/SmartDateRule.php \Drupal\smart_date_recur\Entity\SmartDateRule::getMonthsLimit()

Retrieve the months_limit value from the field definition.

3 calls to SmartDateRule::getMonthsLimit()
Instances::listInstancesOutput in modules/smart_date_recur/src/Controller/Instances.php
Provide a list of rule items with operations to change rule items.
SmartDateRule::getNewInstances in modules/smart_date_recur/src/Entity/SmartDateRule.php
Generate default instances based on rule structure.
SmartDateWidgetBase::massageFormValues in src/Plugin/Field/FieldWidget/SmartDateWidgetBase.php
Massages the form values into the format expected for field values.

File

modules/smart_date_recur/src/Entity/SmartDateRule.php, line 505

Class

SmartDateRule
Defines the Smart date rule entity.

Namespace

Drupal\smart_date_recur\Entity

Code

public static function getMonthsLimit($field_def) {
  $month_limit = NULL;
  if (method_exists($field_def, 'getThirdPartySetting')) {

    // Works for field definitions and rule objects.
    $month_limit = $field_def
      ->getThirdPartySetting('smart_date_recur', 'month_limit');
  }
  elseif (method_exists($field_def, 'getSetting')) {

    // For custom entities, set value in your field definition.
    $month_limit = $field_def
      ->getSetting('month_limit');
  }

  // Default to 12 if no value provided.
  $month_limit = $month_limit ?: 12;
  return $month_limit;
}