class SocialPostHelper in Open Social 10.1.x
Same name and namespace in other branches
- 10.3.x modules/social_features/social_post/src/Service/SocialPostHelper.php \Drupal\social_post\Service\SocialPostHelper
- 10.0.x modules/social_features/social_post/src/Service/SocialPostHelper.php \Drupal\social_post\Service\SocialPostHelper
- 10.2.x modules/social_features/social_post/src/Service/SocialPostHelper.php \Drupal\social_post\Service\SocialPostHelper
Class SocialPostHelper.
@package Drupal\social_post\Service
Hierarchy
- class \Drupal\social_post\Service\SocialPostHelper implements SocialPostHelperInterface
Expanded class hierarchy of SocialPostHelper
1 string reference to 'SocialPostHelper'
- social_post.services.yml in modules/
social_features/ social_post/ social_post.services.yml - modules/social_features/social_post/social_post.services.yml
1 service uses SocialPostHelper
- social_post.helper in modules/
social_features/ social_post/ social_post.services.yml - Drupal\social_post\Service\SocialPostHelper
File
- modules/
social_features/ social_post/ src/ Service/ SocialPostHelper.php, line 13
Namespace
Drupal\social_post\ServiceView source
class SocialPostHelper implements SocialPostHelperInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The current active user.
*
* @var \Drupal\Core\Session\AccountProxyInterface
*/
protected $currentUser;
/**
* SocialPostHelper constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Session\AccountProxyInterface $current_user
* The current active user.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, AccountProxyInterface $current_user) {
$this->entityTypeManager = $entity_type_manager;
$this->currentUser = $current_user;
}
/**
* {@inheritdoc}
*/
public function buildCurrentUserImage() {
$storage = $this->entityTypeManager
->getStorage('profile');
if (!empty($storage)) {
// Load current user.
$account = $this->currentUser
->getAccount();
if ($user_profile = $storage
->loadByUser($account, 'profile')) {
// Load compact notification view mode of the attached profile.
return $this->entityTypeManager
->getViewBuilder('profile')
->view($user_profile, 'compact_notification');
}
}
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SocialPostHelper:: |
protected | property | The current active user. | |
SocialPostHelper:: |
protected | property | The entity type manager. | |
SocialPostHelper:: |
public | function |
Gets image of the user profile. Overrides SocialPostHelperInterface:: |
|
SocialPostHelper:: |
public | function | SocialPostHelper constructor. |