vendor/symfony/src/Symfony/Bundle/SwiftmailerBundle/Logger/MessageLogger.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * This file is part of the Symfony package.
       
     5  *
       
     6  * (c) Fabien Potencier <fabien@symfony.com>
       
     7  *
       
     8  * For the full copyright and license information, please view the LICENSE
       
     9  * file that was distributed with this source code.
       
    10  */
       
    11 
       
    12 namespace Symfony\Bundle\SwiftmailerBundle\Logger;
       
    13 
       
    14 use Symfony\Component\EventDispatcher\Event;
       
    15 
       
    16 /**
       
    17  * MessageLogger.
       
    18  *
       
    19  * @author Fabien Potencier <fabien@symfony.com>
       
    20  * @author Clément JOBEILI <clement.jobeili@gmail.com>
       
    21  */
       
    22 class MessageLogger implements \Swift_Events_SendListener
       
    23 {
       
    24     /**
       
    25      * @var array
       
    26      */
       
    27     protected $messages;
       
    28 
       
    29     public function __construct()
       
    30     {
       
    31         $this->messages = array();
       
    32     }
       
    33 
       
    34     /**
       
    35      * Get the message list
       
    36      *
       
    37      * @return array
       
    38      */
       
    39     public function getMessages()
       
    40     {
       
    41         return $this->messages;
       
    42     }
       
    43 
       
    44     /**
       
    45      * Get the message count
       
    46      *
       
    47      * @return int count
       
    48      */
       
    49     public function countMessages()
       
    50     {
       
    51         return count($this->messages);
       
    52     }
       
    53 
       
    54     /**
       
    55      * Empty the message list
       
    56      *
       
    57      */
       
    58     public function clear()
       
    59     {
       
    60         $this->messages = array();
       
    61     }
       
    62 
       
    63     /**
       
    64      * Invoked immediately before the Message is sent.
       
    65      *
       
    66      * @param \Swift_Events_SendEvent $evt
       
    67      */
       
    68     public function beforeSendPerformed(\Swift_Events_SendEvent $evt)
       
    69     {
       
    70         $this->messages[] = clone $evt->getMessage();
       
    71     }
       
    72 
       
    73     /**
       
    74      * Invoked immediately after the Message is sent.
       
    75      *
       
    76      * @param \Swift_Events_SendEvent $evt
       
    77      */
       
    78     public function sendPerformed(\Swift_Events_SendEvent $evt)
       
    79     {
       
    80     }
       
    81 }