You are here

public function UserExportPluginBase::profileGetAddressFieldValue in Open Social 8.9

Same name and namespace in other branches
  1. 8.3 modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetAddressFieldValue()
  2. 8.4 modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetAddressFieldValue()
  3. 8.5 modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetAddressFieldValue()
  4. 8.6 modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetAddressFieldValue()
  5. 8.7 modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetAddressFieldValue()
  6. 8.8 modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetAddressFieldValue()
  7. 10.3.x modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetAddressFieldValue()
  8. 10.0.x modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetAddressFieldValue()
  9. 10.1.x modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetAddressFieldValue()
  10. 10.2.x modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetAddressFieldValue()

Returns the value for the address field and element within address.

Parameters

string $field_name: The field name to get the value for.

string $address_element: The address element to get the value for, e.g. 'country_code'.

\Drupal\profile\Entity\ProfileInterface $user_profile: The profile to get the data for.

Return value

string Returns the value of the address element for the profile.

Overrides UserExportPluginInterface::profileGetAddressFieldValue

6 calls to UserExportPluginBase::profileGetAddressFieldValue()
UserAddressAdministrative::getValue in modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserAddressAdministrative.php
Returns the value.
UserAddressCountryCode::getValue in modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserAddressCountryCode.php
Returns the value.
UserAddressLine1::getValue in modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserAddressLine1.php
Returns the value.
UserAddressLine2::getValue in modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserAddressLine2.php
Returns the value.
UserAddressLocality::getValue in modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserAddressLocality.php
Returns the value.

... See full list

File

modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php, line 184

Class

UserExportPluginBase
Base class for User export plugin plugins.

Namespace

Drupal\social_user_export\Plugin

Code

public function profileGetAddressFieldValue($field_name, $address_element, ProfileInterface $user_profile = NULL) {
  if ($user_profile === NULL) {
    return '';
  }
  $value = '';
  try {
    $address = $user_profile
      ->get($field_name)
      ->getValue();
    if (isset($address['0'][$address_element])) {
      $value = $address['0'][$address_element];
    }
  } catch (\Exception $e) {
    $value = '';
  }
  return $value;
}