Skip to content

Commit

Permalink
[FEATURE] Assign notification and event instances to email view (#176)
Browse files Browse the repository at this point in the history
Two new variables become accessible in the template of an email:

- `{notification}` – contains the notification instance
- `{event}` – contains the event instance
  • Loading branch information
romm authored Dec 21, 2018
1 parent 6282982 commit af8cb88
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public function getBody()

$view->assign('layout', $layout->getPath());
$view->assign('markers', $this->markers);
$view->assign('notification', $this->notification);
$view->assign('event', $this->event);

return $view->renderWithSlots($this->notification->getBodySlots(), $this->markers);
}
Expand Down
6 changes: 6 additions & 0 deletions Documentation/04-Notification/Email/01-DynamicBody.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ The template below can now be created.
template; see chapter β€œ:ref:`events-property-marker`” for more
information.

- ``{notification}`` – contains the notification instance; see chapter
β€œ:ref:`administrator-objects-notification`” for more information.

- ``{event}`` – contains the event instance; see chapter
β€œ:ref:`administrator-objects-event`” for more information.

.. code-block:: html
:caption: ``EXT:my_extension/Resources/Private/Templates/Mail/ContactEvents/MessageSent.html``

Expand Down
96 changes: 96 additions & 0 deletions Documentation/06-Administrator/06-Objects/Index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
.. include:: ../../Includes.txt

PHP objects
===========

.. _administrator-objects-notification:

Notification
------------

A notification implements the interface
:php:`\CuyZ\Notiz\Core\Notification\Notification`, giving access to the methods
below.

.. tip::

Please note that depending on the type of the notification, even more
methods can be available.

.. container:: table-row

Method
:php:`Notification::getTitle()`
Return type
:php:`string`
Description
Returns the title of the notification.

.. container:: table-row

Method
:php:`Notification::getNotificationDefinition()`
Return type
:php:`\CuyZ\Notiz\Core\Definition\Tree\Notification\NotificationDefinition`
Description
Returns the definition object of the notification.

.. container:: table-row

Method
:php:`Notification::hasEventDefinition()`
Return type
:php:`bool`
Description
Returns whether the notification is bound to an event or not.

.. container:: table-row

Method
:php:`Notification::getEventDefinition()`
Return type
:php:`\CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition`
Description
Returns the definition object of the event bound to the notification.
If no event is bound, an exception is thrown.

.. container:: table-row

Method
:php:`Notification::getEventConfiguration()`
Return type
:php:`array`
Description
Returns the configuration of the event. If no configuration is found, an
empty array is returned.

.. _administrator-objects-event:

Event
-----

An event implements the interface :php:`\CuyZ\Notiz\Core\Event\Event`, giving
access to the following methods:

.. tip::

Please note that depending on the type of the event, even more methods can
be available.

.. container:: table-row

Method
:php:`Event::getDefinition()`
Return type
:php:`\CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition`
Description
Returns the definition object of the event.

.. container:: table-row

Method
:php:`Event::getNotification()`
Return type
:php:`\CuyZ\Notiz\Core\Notification\Notification`
Description
Returns the notification that is being dispatched by this event.

0 comments on commit af8cb88

Please sign in to comment.