Download the PHP package escolalms/templates without Composer
On this page you can find all versions of the php package escolalms/templates. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download escolalms/templates
More information about escolalms/templates
Files in escolalms/templates
Package templates
Short Description Escola Headless LMS templates (for eg Certificates)
License MIT
Informations about the package templates
Templates
Purpose
General purpose of this package is to store various templates in database and assigning them to Events so that content based on these templates is automatically generated and/or sent to users.
Usage
Each template is defined by
channel
: class defining how the template is handledevent
: event to which the template is assigned
For every channel & event pair a single Variables definition is registered, which contains tokens that can be used in the template and replaced with values based on the data from the Event.
Analysing these three example files in tests:
- TestChannel.php
- TestVariables.php
- TestEventWithGetters.php
and looking at the Template
facade is simplest way to understand how this package works.
Facade
There is a Template
facade declared, which is used to register Event-Channel-Variable sets and can be used in testing (as it can be replaced with a fake using Template::fake()
).
To register Event-Channel-Variable set, Template::register($eventClass, $channelClass, $variableClass)
must be called, where:
$eventClass
can be any class that is dispatched as an event in any EscolaLms package$channelClass
must be a class implementingTemplateChannelContract
interface declared in this package$variableClass
must be a class implementingTemplateVariableContract
interface declared in this package
Channels & variables
This package has no Channels or Variables defined, everything should be created in separate packages.
Event Wrapper
EscolaLms\Templates\Events\EventWrapper
is a class that wraps any event before trying to generate notification for it (and feed data from it to Template). This class contains methods for extracting necessary data from Event if that data is not available directly (for example User to which notification is being sent, and any other data that is required by registered Template).
Endpoints
All the endpoints are defined in
Tests
Run ./vendor/bin/phpunit --filter 'EscolaLms\\Templates\\Tests'
to run tests. See tests folder as it's quite good staring point as documentation appendix.
Listeners
EscolaLms\Templates\Listeners\TemplateEventListener
this listeners listens to allEscolaLms
namespace events, checks if event is registered for any Template, and passes the event wrapped inEventWrapper
to processing (so if event is registered and has corresponding Template, notification using that Template will be sent)
Permissions
All versions of templates with dependencies
doctrine/dbal Version ^2|^3
escolalms/core Version ^1.2
escolalms/settings Version ^0
fakerphp/faker Version ^1
laravel/framework Version >=8.0