You are here

public function UserAnalyticsPrivateMessage::getValue in Open Social 8.4

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

Returns the value.

Parameters

\Drupal\user\UserInterface $entity: The User entity to get the value from.

Return value

string The value.

Overrides UserExportPluginBase::getValue

File

modules/social_features/social_private_message/src/Plugin/UserExportPlugin/UserAnalyticsPrivateMessage.php, line 29

Class

UserAnalyticsPrivateMessage
Provides a 'UserAnalyticsPrivateMessage' user export row.

Namespace

Drupal\social_private_message\Plugin\UserExportPlugin

Code

public function getValue(UserInterface $entity) {
  $value = '';

  /** @var \Drupal\private_message\Entity\PrivateMessage $storage */
  try {
    $storage = $this->entityTypeManager
      ->getStorage('private_message');
    if (!empty($storage)) {
      $query = $storage
        ->getQuery();
      $value = (int) $query
        ->condition('owner', $entity
        ->id())
        ->count()
        ->execute();
    }
  } catch (\Exception $e) {
  }
  return $value;
}