| 1 | <?php  | 
            ||
| 14 | class FilterPlugin implements Swift_Events_SendListener  | 
            ||
| 15 | { | 
            ||
| 16 | /**  | 
            ||
| 17 | * @var FilterInterface[]  | 
            ||
| 18 | */  | 
            ||
| 19 | private $filters;  | 
            ||
| 20 | |||
| 21 | public function __construct(array $filters = [])  | 
            ||
| 25 | |||
| 26 | /**  | 
            ||
| 27 | * @param string $email  | 
            ||
| 28 | *  | 
            ||
| 29 | * @return bool  | 
            ||
| 30 | */  | 
            ||
| 31 | 11 | public function filterEmail($email)  | 
            |
| 32 |     { | 
            ||
| 33 | 11 |         foreach ($this->filters as $filter) { | 
            |
| 34 | 11 | $shouldKeepEmail = $filter->checkEmail($email);  | 
            |
| 35 | 11 |             if (!$shouldKeepEmail) { | 
            |
| 36 | 7 | return true;  | 
            |
| 37 | }  | 
            ||
| 38 | }  | 
            ||
| 39 | |||
| 40 | 8 | return false;  | 
            |
| 41 | }  | 
            ||
| 42 | |||
| 43 | /**  | 
            ||
| 44 | * @param array $emails  | 
            ||
| 45 | *  | 
            ||
| 46 | * @return array  | 
            ||
| 47 | */  | 
            ||
| 48 | 11 | public function filterEmailArray(array $emails)  | 
            |
| 58 | |||
| 59 | /**  | 
            ||
| 60 | * Apply whitelist and blacklist to "to", "cc" and "bcc".  | 
            ||
| 61 | *  | 
            ||
| 62 | * @param Swift_Events_SendEvent $event  | 
            ||
| 63 | */  | 
            ||
| 64 | 4 | public function beforeSendPerformed(Swift_Events_SendEvent $event)  | 
            |
| 82 | |||
| 83 | /**  | 
            ||
| 84 | * Do nothing.  | 
            ||
| 85 | *  | 
            ||
| 86 | * @param Swift_Events_SendEvent $event  | 
            ||
| 87 | */  | 
            ||
| 88 | 3 | public function sendPerformed(Swift_Events_SendEvent $event)  | 
            |
| 92 | }  | 
            ||
| 93 |