You are here

protected function ActivityAccessControlHandler::checkIfPersonalNotification in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/custom/activity_creator/src/ActivityAccessControlHandler.php \Drupal\activity_creator\ActivityAccessControlHandler::checkIfPersonalNotification()
  2. 8.2 modules/custom/activity_creator/src/ActivityAccessControlHandler.php \Drupal\activity_creator\ActivityAccessControlHandler::checkIfPersonalNotification()
  3. 8.3 modules/custom/activity_creator/src/ActivityAccessControlHandler.php \Drupal\activity_creator\ActivityAccessControlHandler::checkIfPersonalNotification()
  4. 8.4 modules/custom/activity_creator/src/ActivityAccessControlHandler.php \Drupal\activity_creator\ActivityAccessControlHandler::checkIfPersonalNotification()
  5. 8.5 modules/custom/activity_creator/src/ActivityAccessControlHandler.php \Drupal\activity_creator\ActivityAccessControlHandler::checkIfPersonalNotification()
  6. 8.6 modules/custom/activity_creator/src/ActivityAccessControlHandler.php \Drupal\activity_creator\ActivityAccessControlHandler::checkIfPersonalNotification()
  7. 8.7 modules/custom/activity_creator/src/ActivityAccessControlHandler.php \Drupal\activity_creator\ActivityAccessControlHandler::checkIfPersonalNotification()
  8. 8.8 modules/custom/activity_creator/src/ActivityAccessControlHandler.php \Drupal\activity_creator\ActivityAccessControlHandler::checkIfPersonalNotification()
  9. 10.3.x modules/custom/activity_creator/src/ActivityAccessControlHandler.php \Drupal\activity_creator\ActivityAccessControlHandler::checkIfPersonalNotification()
  10. 10.0.x modules/custom/activity_creator/src/ActivityAccessControlHandler.php \Drupal\activity_creator\ActivityAccessControlHandler::checkIfPersonalNotification()
  11. 10.1.x modules/custom/activity_creator/src/ActivityAccessControlHandler.php \Drupal\activity_creator\ActivityAccessControlHandler::checkIfPersonalNotification()
  12. 10.2.x modules/custom/activity_creator/src/ActivityAccessControlHandler.php \Drupal\activity_creator\ActivityAccessControlHandler::checkIfPersonalNotification()

Check if this is a personal notification.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: Entity object.

Return value

bool Returns TRUE if entity is personal notification, FALSE if it isn't.

1 call to ActivityAccessControlHandler::checkIfPersonalNotification()
ActivityAccessControlHandler::checkAccess in modules/custom/activity_creator/src/ActivityAccessControlHandler.php
Performs access checks.

File

modules/custom/activity_creator/src/ActivityAccessControlHandler.php, line 90

Class

ActivityAccessControlHandler
Access controller for the Activity entity.

Namespace

Drupal\activity_creator

Code

protected function checkIfPersonalNotification(EntityInterface $entity) {
  $recipient = $entity
    ->getRecipient();
  $value = FALSE;
  if (!empty($recipient) && $recipient['0']['target_type'] === 'user') {

    // This could be personalised, but first lets check the destinations.
    $destinations = $entity
      ->getDestinations();
    $is_notification = in_array('notifications', $destinations);

    // It is only personal if the only destination is notifications.
    if (count($destinations) <= 1 && $is_notification === TRUE) {
      $value = TRUE;
    }
  }
  return $value;
}