ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Monolog\Handler\MandrillHandler Class Reference

MandrillHandler uses cURL to send the emails to the Mandrill API. More...

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

Public Member Functions

 __construct ($apiKey, $message, $level=Logger::ERROR, $bubble=true)
 
- 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...
 
- 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

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

Detailed Description

MandrillHandler uses cURL to send the emails to the Mandrill API.

Author
Adam Nicholson adamn.nosp@m.icho.nosp@m.lson1.nosp@m.0@gm.nosp@m.ail.c.nosp@m.om

Definition at line 21 of file MandrillHandler.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Handler\MandrillHandler::__construct (   $apiKey,
  $message,
  $level = Logger::ERROR,
  $bubble = true 
)
Parameters
string$apiKeyA valid Mandrill API key
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 32 of file MandrillHandler.php.

References Monolog\Handler\MandrillHandler\$apiKey, Monolog\Handler\AbstractHandler\$bubble, Monolog\Handler\AbstractHandler\$level, and Monolog\Handler\MandrillHandler\$message.

33  {
34  parent::__construct($level, $bubble);
35 
36  if (!$message instanceof \Swift_Message && is_callable($message)) {
37  $message = call_user_func($message);
38  }
39  if (!$message instanceof \Swift_Message) {
40  throw new \InvalidArgumentException('You must provide either a Swift_Message instance or a callable returning it');
41  }
42  $this->message = $message;
43  $this->apiKey = $apiKey;
44  }

Member Function Documentation

◆ send()

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

{}

Definition at line 49 of file MandrillHandler.php.

References Monolog\Handler\MandrillHandler\$message, array, Monolog\Handler\Curl\Util\execute(), and time.

50  {
51  $message = clone $this->message;
52  $message->setBody($content);
53  $message->setDate(time());
54 
55  $ch = curl_init();
56 
57  curl_setopt($ch, CURLOPT_URL, 'https://mandrillapp.com/api/1.0/messages/send-raw.json');
58  curl_setopt($ch, CURLOPT_POST, 1);
59  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
60  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
61  'key' => $this->apiKey,
62  'raw_message' => (string) $message,
63  'async' => false,
64  )));
65 
66  Curl\Util::execute($ch);
67  }
static execute($ch, $retries=5, $closeAfterDone=true)
Executes a CURL request with optional retries and exception on failure.
Definition: Util.php:32
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

Field Documentation

◆ $apiKey

Monolog\Handler\MandrillHandler::$apiKey
protected

Definition at line 24 of file MandrillHandler.php.

Referenced by Monolog\Handler\MandrillHandler\__construct().

◆ $message

Monolog\Handler\MandrillHandler::$message
protected

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