ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Monolog\Handler\SwiftMailerHandler Class Reference

SwiftMailerHandler uses Swift_Mailer to send the emails. More...

+ Inheritance diagram for Monolog\Handler\SwiftMailerHandler:
+ Collaboration diagram for Monolog\Handler\SwiftMailerHandler:

Public Member Functions

 __construct (\Swift_Mailer $mailer, $message, $level=Logger::ERROR, $bubble=true)
 
 __get ($name)
 BC getter, to be removed in 2.0. More...
 
- Public Member Functions inherited from Monolog\Handler\MailHandler
 handleBatch (array $records)
 {Handles a set of records at once.
Parameters
array$recordsThe records to handle (an array of record arrays)
} More...
 
- Public Member Functions inherited from Monolog\Handler\AbstractProcessingHandler
 handle (array $record)
 {Handles a record.All records may be passed to this method, and the handler should discard those that it does not want to handle.The return value of this function controls the bubbling process of the handler stack. Unless the bubbling is interrupted (by returning true), the Logger class will keep on calling further handlers in the stack with a given log record.
Parameters
array$recordThe record to handle
Returns
Boolean true means that this handler handled the record, and that bubbling is not permitted. false means the record was either not processed or that this handler allows bubbling.
} More...
 
- Public Member Functions inherited from Monolog\Handler\AbstractHandler
 __construct ($level=Logger::DEBUG, $bubble=true)
 
 isHandling (array $record)
 {Checks whether the given record will be handled by this handler.This is mostly done for performance reasons, to avoid calling processors for nothing.Handlers should still check the record levels within handle(), returning false in isHandling() is no guarantee that handle() will not be called, and isHandling() might not be called for a given record.
Parameters
array$recordPartial log record containing only a level key
Returns
Boolean
} More...
 
 handleBatch (array $records)
 {Handles a set of records at once.
Parameters
array$recordsThe records to handle (an array of record arrays)
} More...
 
 close ()
 Closes the handler. More...
 
 pushProcessor ($callback)
 {Adds a processor in the stack.
Parameters
callable$callback
Returns
self
} More...
 
 popProcessor ()
 {Removes the processor on top of the stack and returns it.
Returns
callable
} More...
 
 setFormatter (FormatterInterface $formatter)
 {Sets the formatter.
Parameters
FormatterInterface$formatter
Returns
self
} More...
 
 getFormatter ()
 {Gets the formatter.
Returns
FormatterInterface
} More...
 
 setLevel ($level)
 Sets minimum logging level at which this handler will be triggered. More...
 
 getLevel ()
 Gets minimum logging level at which this handler will be triggered. More...
 
 setBubble ($bubble)
 Sets the bubbling behavior. More...
 
 getBubble ()
 Gets the bubbling behavior. More...
 
 __destruct ()
 

Protected Member Functions

 send ($content, array $records)
 {} More...
 
 buildMessage ($content, array $records)
 Creates instance of Swift_Message to be sent. More...
 
- Protected Member Functions inherited from Monolog\Handler\MailHandler
 send ($content, array $records)
 Send a mail with the given content. More...
 
 write (array $record)
 {} More...
 
 getHighestRecord (array $records)
 
- Protected Member Functions inherited from Monolog\Handler\AbstractProcessingHandler
 write (array $record)
 Writes the record down to the log of the implementing handler. More...
 
 processRecord (array $record)
 Processes a record. More...
 
- Protected Member Functions inherited from Monolog\Handler\AbstractHandler
 getDefaultFormatter ()
 Gets the default formatter. More...
 

Protected Attributes

 $mailer
 
- Protected Attributes inherited from Monolog\Handler\AbstractHandler
 $level = Logger::DEBUG
 
 $bubble = true
 
 $formatter
 
 $processors = array()
 

Private Attributes

 $messageTemplate
 

Detailed Description

SwiftMailerHandler uses Swift_Mailer to send the emails.

Author
Gyula Sallai

Definition at line 22 of file SwiftMailerHandler.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Handler\SwiftMailerHandler::__construct ( \Swift_Mailer  $mailer,
  $message,
  $level = Logger::ERROR,
  $bubble = true 
)
Parameters
\Swift_Mailer$mailerThe mailer to use
callable | \Swift_Message$messageAn example message for real messages, only the body will be replaced
int$levelThe minimum logging level at which this handler will be triggered
Boolean$bubbleWhether the messages that are handled can bubble up the stack or not

Definition at line 33 of file SwiftMailerHandler.php.

References Monolog\Handler\AbstractHandler\$bubble, Monolog\Handler\AbstractHandler\$level, Monolog\Handler\SwiftMailerHandler\$mailer, and $message.

34  {
35  parent::__construct($level, $bubble);
36 
37  $this->mailer = $mailer;
38  $this->messageTemplate = $message;
39  }
catch(Exception $e) $message

Member Function Documentation

◆ __get()

Monolog\Handler\SwiftMailerHandler::__get (   $name)

BC getter, to be removed in 2.0.

Definition at line 84 of file SwiftMailerHandler.php.

References $name, array, and Monolog\Handler\SwiftMailerHandler\buildMessage().

85  {
86  if ($name === 'message') {
87  trigger_error('SwiftMailerHandler->message is deprecated, use ->buildMessage() instead to retrieve the message', E_USER_DEPRECATED);
88 
89  return $this->buildMessage(null, array());
90  }
91 
92  throw new \InvalidArgumentException('Invalid property '.$name);
93  }
if($format !==null) $name
Definition: metadata.php:146
Create styles array
The data for the language used.
buildMessage($content, array $records)
Creates instance of Swift_Message to be sent.
+ Here is the call graph for this function:

◆ buildMessage()

Monolog\Handler\SwiftMailerHandler::buildMessage (   $content,
array  $records 
)
protected

Creates instance of Swift_Message to be sent.

Parameters
string$contentformatted email body to be sent
array$recordsLog records that formed the content
Returns

Definition at line 56 of file SwiftMailerHandler.php.

References $message, Monolog\Handler\SwiftMailerHandler\$messageTemplate, and time.

Referenced by Monolog\Handler\SwiftMailerHandler\__get(), and Monolog\Handler\SwiftMailerHandler\send().

57  {
58  $message = null;
59  if ($this->messageTemplate instanceof \Swift_Message) {
61  $message->generateId();
62  } elseif (is_callable($this->messageTemplate)) {
63  $message = call_user_func($this->messageTemplate, $content, $records);
64  }
65 
66  if (!$message instanceof \Swift_Message) {
67  throw new \InvalidArgumentException('Could not resolve message as instance of Swift_Message or a callable returning it');
68  }
69 
70  if ($records) {
71  $subjectFormatter = new LineFormatter($message->getSubject());
72  $message->setSubject($subjectFormatter->format($this->getHighestRecord($records)));
73  }
74 
75  $message->setBody($content);
76  $message->setDate(time());
77 
78  return $message;
79  }
$records
Definition: simple_test.php:22
catch(Exception $e) $message
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the caller graph for this function:

◆ send()

Monolog\Handler\SwiftMailerHandler::send (   $content,
array  $records 
)
protected

{}

Definition at line 44 of file SwiftMailerHandler.php.

References Monolog\Handler\SwiftMailerHandler\buildMessage().

45  {
46  $this->mailer->send($this->buildMessage($content, $records));
47  }
$records
Definition: simple_test.php:22
buildMessage($content, array $records)
Creates instance of Swift_Message to be sent.
+ Here is the call graph for this function:

Field Documentation

◆ $mailer

Monolog\Handler\SwiftMailerHandler::$mailer
protected

◆ $messageTemplate

Monolog\Handler\SwiftMailerHandler::$messageTemplate
private

The documentation for this class was generated from the following file: