UserAnalyticsPrivateMessage.php in Open Social 10.3.x
Same filename and directory in other branches
- 8.9 modules/social_features/social_private_message/src/Plugin/UserExportPlugin/UserAnalyticsPrivateMessage.php
- 8.3 modules/social_features/social_private_message/src/Plugin/UserExportPlugin/UserAnalyticsPrivateMessage.php
- 8.4 modules/social_features/social_private_message/src/Plugin/UserExportPlugin/UserAnalyticsPrivateMessage.php
- 8.5 modules/social_features/social_private_message/src/Plugin/UserExportPlugin/UserAnalyticsPrivateMessage.php
- 8.6 modules/social_features/social_private_message/src/Plugin/UserExportPlugin/UserAnalyticsPrivateMessage.php
- 8.7 modules/social_features/social_private_message/src/Plugin/UserExportPlugin/UserAnalyticsPrivateMessage.php
- 8.8 modules/social_features/social_private_message/src/Plugin/UserExportPlugin/UserAnalyticsPrivateMessage.php
- 10.0.x modules/social_features/social_private_message/src/Plugin/UserExportPlugin/UserAnalyticsPrivateMessage.php
- 10.1.x modules/social_features/social_private_message/src/Plugin/UserExportPlugin/UserAnalyticsPrivateMessage.php
- 10.2.x modules/social_features/social_private_message/src/Plugin/UserExportPlugin/UserAnalyticsPrivateMessage.php
File
modules/social_features/social_private_message/src/Plugin/UserExportPlugin/UserAnalyticsPrivateMessage.phpView source
<?php
namespace Drupal\social_private_message\Plugin\UserExportPlugin;
use Drupal\Core\Entity\ContentEntityStorageInterface;
use Drupal\social_user_export\Plugin\UserExportPluginBase;
use Drupal\user\UserInterface;
/**
* Provides a 'UserAnalyticsPrivateMessage' user export row.
*
* @UserExportPlugin(
* id = "user_private_message",
* label = @Translation("Number of Private messages"),
* weight = -180,
* )
*/
class UserAnalyticsPrivateMessage extends UserExportPluginBase {
/**
* {@inheritdoc}
*/
public function getHeader() {
return $this
->t('Number of Private messages');
}
/**
* {@inheritdoc}
*/
public function getValue(UserInterface $entity) {
$value = '';
try {
$storage = $this->entityTypeManager
->getStorage('private_message');
if ($storage instanceof ContentEntityStorageInterface) {
$value = (int) $storage
->getQuery()
->condition('owner', $entity
->id())
->count()
->execute();
}
} catch (\Exception $e) {
}
return $value;
}
}
Classes
Name | Description |
---|---|
UserAnalyticsPrivateMessage | Provides a 'UserAnalyticsPrivateMessage' user export row. |