You are here

public function SmartDateRule::getFieldSettings in Smart Date 3.3.x

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

Retrieve a setting from the field config.

File

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

Class

SmartDateRule
Defines the Smart date rule entity.

Namespace

Drupal\smart_date_recur\Entity

Code

public function getFieldSettings($setting_name, $module = 'smart_date_recur') {
  $entity_type = $this->entity_type
    ->getString();
  $bundle = $this->bundle
    ->getString();
  $field_name = $this->field_name
    ->getString();
  $bundle_fields = \Drupal::getContainer()
    ->get('entity_field.manager')
    ->getFieldDefinitions($entity_type, $bundle);
  $field_def = $bundle_fields[$field_name];
  if ($field_def instanceof FieldConfigInterface) {
    $value = $field_def
      ->getThirdPartySetting($module, $setting_name);
  }
  elseif ($field_def instanceof BaseFieldDefinition) {

    // TODO: Document that for custom entities, you must enable recurring
    // functionality by adding ->setSetting('allow_recurring', TRUE)
    // to your field definition.
    $value = $field_def
      ->getSetting($setting_name);
  }
  else {

    // Not sure what other method we can provide to define this.
    $value = FALSE;
  }
  return $value;
}