RecipientHandlerEntityBase.php in Simplenews 3.x        
                          
                  
                        
  
  
  
  
File
  src/Plugin/simplenews/RecipientHandler/RecipientHandlerEntityBase.php
  
    View source  
  <?php
namespace Drupal\simplenews\Plugin\simplenews\RecipientHandler;
abstract class RecipientHandlerEntityBase extends RecipientHandlerBase {
  
  public function addToSpool() {
    $query = $this
      ->buildEntityQuery();
    $ids = $query
      ->execute();
    $field = $query
      ->getEntityTypeId() == 'user' ? 'uid' : 'snid';
    $this
      ->addArrayToSpool($field, $ids);
    return count($ids);
  }
  
  protected function doCount() {
    return $this
      ->buildEntityQuery()
      ->count()
      ->execute();
  }
  
  protected abstract function buildEntityQuery();
}