You are here

protected function SocialProfileFieldsFlushForm::getUnselectedFields in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm::getUnselectedFields()
  2. 8.2 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm::getUnselectedFields()
  3. 8.3 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm::getUnselectedFields()
  4. 8.4 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm::getUnselectedFields()
  5. 8.5 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm::getUnselectedFields()
  6. 8.6 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm::getUnselectedFields()
  7. 8.7 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm::getUnselectedFields()
  8. 8.8 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm::getUnselectedFields()
  9. 10.0.x modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm::getUnselectedFields()
  10. 10.1.x modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm::getUnselectedFields()
  11. 10.2.x modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm::getUnselectedFields()

Function that return an array of field names.

Return value

array An array of field names.

2 calls to SocialProfileFieldsFlushForm::getUnselectedFields()
SocialProfileFieldsFlushForm::getDescription in modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php
Returns additional text to display as a description.
SocialProfileFieldsFlushForm::submitForm in modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php
Form submission handler.

File

modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php, line 140

Class

SocialProfileFieldsFlushForm
Class SocialProfileFieldsFlushForm.

Namespace

Drupal\social_profile_fields\Form

Code

protected function getUnselectedFields() {
  $profile_fields = $this->fieldStorage
    ->loadByProperties([
    'entity_type' => 'profile',
    'bundle' => 'profile',
  ]);
  $settings = $this->configFactory
    ->get('social_profile_fields.settings');
  $empty = [];

  /** @var \Drupal\field\Entity\FieldConfig $value */
  foreach ($profile_fields as $key => $value) {
    $setting_id = str_replace('.', '_', $key);
    $sval = $settings
      ->get($setting_id);
    if (isset($sval) && $sval == FALSE) {
      $empty[] = $value
        ->getName();
    }
    if ($setting_id === 'profile_profile_field_profile_address') {
      if (isset($sval) && $sval == FALSE) {
        $empty[] = 'country';
      }
      $city_val = $settings
        ->get('profile_address_field_city');
      if (isset($city_val) && $city_val == FALSE) {
        $empty[] = 'locality';
      }
      $address_val = $settings
        ->get('profile_address_field_address');
      if (isset($address_val) && $address_val == FALSE) {
        $empty[] = 'addressLine1';
      }
      $postalcode_val = $settings
        ->get('profile_address_field_postalcode');
      if (isset($postalcode_val) && $postalcode_val == FALSE) {
        $empty[] = 'postalCode';
      }
      $administrativearea_val = $settings
        ->get('profile_address_field_administrative_area');
      if (isset($administrativearea_val) && $administrativearea_val == FALSE) {
        $empty[] = 'administrativeArea';
      }
    }
  }
  return $empty;
}