MailTarget
extends BaseTarget
in package
A BaseTarget is used to handle new Basenotifications. A BaseTarget may send nofication information to external services in specific formats or use specific protocols.
Tags
Table of Contents
Properties
- $acknowledgeFlag : string
- Defines the acknowledge flag in the notification record.
- $active : bool
- This flag can be used to deactivate a target within the configuration.
- $defaultSetting : bool
- Enable this target by default.
- $id : string
- Unique target id has to be defined by subclasses.
- $renderer : Renderer
- Default Renderer for this BaseTarget
- $title : string
- Holds the title of this instance.
- $view : array<string|int, mixed>
Methods
- __call() : mixed
- Calls the named method which is not a class method.
- __construct() : mixed
- Constructor.
- __get() : mixed
- Returns the value of an object property.
- __isset() : bool
- Checks if a property is set, i.e. defined and not null.
- __set() : mixed
- Sets value of an object property.
- __unset() : mixed
- Sets an object property to null.
- acknowledge() : mixed
- Used to acknowledge the seding/processing of the given $notification.
- canGetProperty() : bool
- Returns a value indicating whether a property can be read.
- canSetProperty() : bool
- Returns a value indicating whether a property can be set.
- className() : string
- Returns the fully qualified name of this class.
- getId() : string
- Static access to the target id.
- getRenderer() : Renderer
- getSettingKey() : string
- Returns the setting key for this target of the given $category.
- getTitle() : string
- handle() : mixed
- Used to handle a BaseNotification for a given $user.
- hasMethod() : bool
- Returns a value indicating whether a method is defined.
- hasProperty() : bool
- Returns a value indicating whether a property is defined.
- init() : mixed
- Initializes the object.
- isAcknowledged() : bool
- isActive() : bool
- Some BaseTargets may need to be activated first or require a certain permission in order to be used.
- isCategoryEnabled() : bool
- Returns the enabled setting of this target for the given $category.
- isEditable() : bool
- Checks if the settings for this target are editable.
- isEnabled() : bool
- Checks if the given $notification is enabled for this target.
- send() : mixed
- Used to process a $notification for the given $user.
- sendBulk() : mixed
- Used for handling the given $notification for multiple $users.
Properties
$acknowledgeFlag
Defines the acknowledge flag in the notification record.
public
string
$acknowledgeFlag
If not set, the notification target does not support the acknowledgement of a notification, or provides an custom implemention.
Tags
$active
This flag can be used to deactivate a target within the configuration.
public
bool
$active
= true
Tags
$defaultSetting
Enable this target by default.
public
bool
$defaultSetting
= true
$id
Unique target id has to be defined by subclasses.
public
string
$id
= 'email'
Tags
$renderer
Default Renderer for this BaseTarget
public
Renderer
$renderer
$title
Holds the title of this instance.
public
string
$title
$view
public
array<string|int, mixed>
$view
= ['html' => '@notification/views/mails/wrapper', 'text' => '@notification/views/mails/plaintext/wrapper']
Notification mail layout.
Methods
__call()
Calls the named method which is not a class method.
public
__call(string $name, array<string|int, mixed> $params) : mixed
Do not call this method directly as it is a PHP magic method that will be implicitly called when an unknown method is being invoked.
Parameters
- $name : string
-
the method name
- $params : array<string|int, mixed>
-
method parameters
Tags
Return values
mixed —the method return value
__construct()
Constructor.
public
__construct([array<string|int, mixed> $config = [] ]) : mixed
The default implementation does two things:
- Initializes the object with the given configuration
$config
. - Call [[init()]].
If this method is overridden in a child class, it is recommended that
- the last parameter of the constructor is a configuration array, like
$config
here. - call the parent implementation at the end of the constructor.
Parameters
- $config : array<string|int, mixed> = []
-
name-value pairs that will be used to initialize the object properties
__get()
Returns the value of an object property.
public
__get(string $name) : mixed
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $value = $object->property;
.
Parameters
- $name : string
-
the property name
Tags
Return values
mixed —the property value
__isset()
Checks if a property is set, i.e. defined and not null.
public
__isset(string $name) : bool
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing isset($object->property)
.
Note that if the property is not defined, false will be returned.
Parameters
- $name : string
-
the property name or the event name
Tags
Return values
bool —whether the named property is set (not null).
__set()
Sets value of an object property.
public
__set(string $name, mixed $value) : mixed
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $object->property = $value;
.
Parameters
- $name : string
-
the property name or the event name
- $value : mixed
-
the property value
Tags
__unset()
Sets an object property to null.
public
__unset(string $name) : mixed
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing unset($object->property)
.
Note that if the property is not defined, this method will do nothing. If the property is read-only, it will throw an exception.
Parameters
- $name : string
-
the property name
Tags
acknowledge()
Used to acknowledge the seding/processing of the given $notification.
public
acknowledge(BaseNotification $notification[, bool $state = true ]) : mixed
Parameters
- $notification : BaseNotification
-
notification to be acknowledged
- $state : bool = true
-
true if successful otherwise false
canGetProperty()
Returns a value indicating whether a property can be read.
public
canGetProperty(string $name[, bool $checkVars = true ]) : bool
A property is readable if:
- the class has a getter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
Tags
Return values
bool —whether the property can be read
canSetProperty()
Returns a value indicating whether a property can be set.
public
canSetProperty(string $name[, bool $checkVars = true ]) : bool
A property is writable if:
- the class has a setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
Tags
Return values
bool —whether the property can be written
className()
Returns the fully qualified name of this class.
public
static className() : string
Tags
Return values
string —the fully qualified name of this class.
getId()
Static access to the target id.
public
static getId() : string
Return values
stringgetRenderer()
public
getRenderer() : Renderer
Tags
Return values
Renderer —default renderer for this target.
getSettingKey()
Returns the setting key for this target of the given $category.
public
getSettingKey(NotificationCategory $category) : string
Parameters
- $category : NotificationCategory
Return values
stringgetTitle()
public
getTitle() : string
Tags
Return values
string —Human readable title for views.
handle()
Used to handle a BaseNotification for a given $user.
public
handle(BaseNotification $notification, User $recipient) : mixed
Parameters
- $notification : BaseNotification
- $recipient : User
Tags
hasMethod()
Returns a value indicating whether a method is defined.
public
hasMethod(string $name) : bool
The default implementation is a call to php function method_exists()
.
You may override this method when you implemented the php magic method __call()
.
Parameters
- $name : string
-
the method name
Return values
bool —whether the method is defined
hasProperty()
Returns a value indicating whether a property is defined.
public
hasProperty(string $name[, bool $checkVars = true ]) : bool
A property is defined if:
- the class has a getter or setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
Tags
Return values
bool —whether the property is defined
init()
Initializes the object.
public
init() : mixed
Tags
isAcknowledged()
public
isAcknowledged(BaseNotification $notification) : bool
Parameters
- $notification : BaseNotification
Return values
bool —Check if the given $notification has already been processed.
isActive()
Some BaseTargets may need to be activated first or require a certain permission in order to be used.
public
isActive([User $user = null ]) : bool
Parameters
- $user : User = null
Tags
Return values
boolisCategoryEnabled()
Returns the enabled setting of this target for the given $category.
public
isCategoryEnabled(NotificationCategory $category[, User $user = null ]) : bool
Parameters
- $category : NotificationCategory
- $user : User = null
Return values
boolisEditable()
Checks if the settings for this target are editable.
public
isEditable([User $user = null ]) : bool
Parameters
- $user : User = null
Return values
boolisEnabled()
Checks if the given $notification is enabled for this target.
public
isEnabled(BaseNotification $notification[, User $user = null ]) : bool
If the $notification is not part of a NotificationCategory the $defaultSetting of this BaseTarget is returned.
If this BaseTarget is not active for the given $user, this function will return false.
Parameters
- $notification : BaseNotification
- $user : User = null
Tags
Return values
boolsend()
Used to process a $notification for the given $user.
public
send(BaseNotification $notification, User $user) : mixed
By default the $noification will be marked as acknowledged before processing. The processing is triggerd by calling $this->handle. If the processing fails the acknowledged mark will be set to false.
Parameters
- $notification : BaseNotification
- $user : User
sendBulk()
Used for handling the given $notification for multiple $users.
public
sendBulk(BaseNotification $notification, array<string|int, User> $users) : mixed
Parameters
- $notification : BaseNotification
- $users : array<string|int, User>