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;
  }
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;
  }
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 ; }
Check if this is a personal notification.

@param \Drupal\Core\Entity\EntityInterface $entity
Entity object.

@return bool
Returns TRUE if entity is personal notification, FALSE if it isn't.
Check if this is a personal notification .