Download the PHP package thomasvargiu/pami-module without Composer
On this page you can find all versions of the php package thomasvargiu/pami-module. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thomasvargiu/pami-module
More information about thomasvargiu/pami-module
Files in thomasvargiu/pami-module
Package pami-module
Short Description Laminas module for PAMI Asterisk Library
License MIT
Homepage https://github.com/thomasvargiu/pami-module
Informations about the package pami-module
PamiModule
A ZF module for PAMI library.
Configuration
First, you should define connection and client options in your configuration. Client options are all optional.
Then you can retrieve two services from the service locator:
- : PamiModule client
PamiModule Client
You can get the client from the service locator.
Methods
The original client (the connection) is injected into the , and the actions delegates the original client.
Mapped Actions:
PamiModule | PAMI |
---|---|
Events
The client has an instance injected into it.
The following methods will trigger events with the same name of the method and and suffix:
The events have param in event and and params in event, allowing you to modify the action before it will be dispatched or to cache responses.
PAMI events
All PAMI events are forwarded to the event manager that will trigger an event ().
The name of the event will be (example: ).
Of course, you can acces to the original event to retrieve event data (see example below).
The event target is the client.
Example:
Multiple clients
You can retrieve clients with service names:
Multiple clients sharing the same connection
You can create another client with the same connection of another one:
Getting the original PAMI client
You can retrieve the original PAMI client in two ways:
From service locator:
From the client:
Available Listeners
There are listeners ready to be used.
ConnectionStatusListener
This listener takes care to maintain a connection status, and to call method when is required.
It can be useful when you share the client between some services, because you don't need to call methods
without to know the connection status. You can call directly and methods and it will
automatically calls if a connection is not already opened.
You can also use and methods at any point of your application, the listener takes
care to open or close connection only if is really necessary.
In order to use this listener, you can't use the connection (the original client) directly, because the connection
status is maintained listening the client events.
If you want to use the listener in multiple clients, you need to attach a new instance of it for every client.
You have to attach it to the client before to call any methods, so the best way is to use a delegator factory. This library provide a ready to use delegator factory:
Note: if you share some connection between clients, you must attach the same listener to the clients, so you need to create your custom DelegatorFactory.
CacheListener
You can use the CacheListener to cache results of some actions. The constructor require a cache storage instance and the action names that listener can cache response.
All versions of pami-module with dependencies
ext-json Version *
marcelog/pami Version ^2.0.2
psr/event-dispatcher Version ^1.0
psr/simple-cache Version ^1.0
psr/container Version ^1.0