You are here

protected function AdsenseRevenueSharingBasicSettings::getProfileFields in Google AdSense integration 8

Create the list for the profile field.

Return value

array array of fields with the field IDs as keys and the field titles as values

1 call to AdsenseRevenueSharingBasicSettings::getProfileFields()
AdsenseRevenueSharingBasicSettings::buildForm in oldcode/revenue_sharing_basic/src/Form/AdsenseRevenueSharingBasicSettings.php
Form constructor.

File

oldcode/revenue_sharing_basic/src/Form/AdsenseRevenueSharingBasicSettings.php, line 137

Class

AdsenseRevenueSharingBasicSettings
Form for the adsense revenue sharing settings.

Namespace

Drupal\adsense_revenue_sharing_basic\Form

Code

protected function getProfileFields() {
  $profile_list = [];

  // Start with the core fields.

  /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entityFieldManager */
  $entityFieldManager = \Drupal::service('entity_field.manager');
  $fields = $entityFieldManager
    ->getFieldDefinitions('user', 'user');
  foreach ($fields as $field) {
    if ($field instanceof FieldConfig && $field
      ->getType() == 'string') {

      /** @var \Drupal\field\Entity\FieldConfig $field */
      $profile_list['field:' . $field
        ->getName()] = $field
        ->label();
    }
  }

  // Get fields from the Profile module.
  // @todo adapt this to the profile module.

  /* @codingStandardsIgnoreStart
     if (\Drupal::moduleHandler()->moduleExists('profile')) {
       $result = db_query("SELECT fid, name, title FROM {profile_field} WHERE type='textfield' ORDER BY fid");
       foreach ($result as $row) {
         $profile_list['profile:' . $row->name] = $row->title;
       }
     }
     @codingStandardsIgnoreEnd */
  return $profile_list;
}