\User\NotificationNotificationManager

A simple class for handling user notification emails.

Usage:

$user = $this->Users->get($id);
$optionsArray = ['updateToken' => false];
$result = NotificationManager::welcome($user, $optionsArray)->send();

This class comes with a few built-in messages:

  • welcome
  • activated
  • blocked
  • cancelRequest
  • canceled
  • passwordRequest

Registering new messages:

More messages can be registered (or overwritten) to this class using the addMessage() method as follows:

NotificationManager::addMessage('bye', 'ClassName\Extending\BaseMessage');

After registered you can start sending messages of bye type as below:

NotificationManager::bye($user, $optionsArray)->send();

Summary

Methods
Properties
Constants
__callStatic()
messages()
addMessage()
welcome()
activated()
blocked()
cancelRequest()
canceled()
passwordRequest()
No public properties found
No constants found
No protected methods found
$_messages
N/A
No private methods found
No private properties found
N/A

Properties

$_messages

$_messages : array

Defaults registered messages.

Type

array

Methods

__callStatic()

__callStatic(string $method, array $arguments) : mixed

Magic method for dispatching to message handlers.

Parameters

string $method

Name of the method

array $arguments

Arguments for the invoked method

Returns

mixed

messages()

messages() : array

Gets a list of all registered messages.

Returns

array

addMessage()

addMessage(string $name,  $handler) : string|\User\Notification\Message\BaseMessage

Looks for variables tags in the given message and replaces with their corresponding values. For example, "[site:name] will be replaced with user's real name.

Parameters

string $name

CamelizedName for when using this message

$handler

Returns

string|\User\Notification\Message\BaseMessage

Message handler. It can be either a string for a class name to instance, or a constructed message handler object.

welcome()

welcome(\Cake\Datasource\EntityInterface $user, array $config) : \User\Notification\Message\WelcomeMessage

Parameters

\Cake\Datasource\EntityInterface $user
array $config

Returns

\User\Notification\Message\WelcomeMessage

activated()

activated(\Cake\Datasource\EntityInterface $user, array $config) : \User\Notification\Message\ActivatedMessage

Parameters

\Cake\Datasource\EntityInterface $user
array $config

Returns

\User\Notification\Message\ActivatedMessage

blocked()

blocked(\Cake\Datasource\EntityInterface $user, array $config) : \User\Notification\Message\BlockedMessage

Parameters

\Cake\Datasource\EntityInterface $user
array $config

Returns

\User\Notification\Message\BlockedMessage

cancelRequest()

cancelRequest(\Cake\Datasource\EntityInterface $user, array $config) : \User\Notification\Message\CancelRequestMessage

Parameters

\Cake\Datasource\EntityInterface $user
array $config

Returns

\User\Notification\Message\CancelRequestMessage

canceled()

canceled(\Cake\Datasource\EntityInterface $user, array $config) : \User\Notification\Message\CanceledMessage

Parameters

\Cake\Datasource\EntityInterface $user
array $config

Returns

\User\Notification\Message\CanceledMessage

passwordRequest()

passwordRequest(\Cake\Datasource\EntityInterface $user, array $config) : \User\Notification\Message\PasswordRequestMessage

Parameters

\Cake\Datasource\EntityInterface $user
array $config

Returns

\User\Notification\Message\PasswordRequestMessage