PAMI
PAMI copied to clipboard
event filters
when i process events, i need to filter them based on specific event data. i could use predicates as closures, but that solution is too hard and complex, especially if filters have to be dynamic. i recommend closures if you really have to filter with some particular criteria, but if you just need to filter evaluating event data, i don't think they are the optimal solution.
that's why i added the capability of specifying an array of filters during event registration. filters are specified as regular expressions. here's an example:
$client->registerEventListener(
function($event) {var_dump($event);},
array(
'event' => '/Hangup/',
'channel' => '/Local\/27.*/',
)
);
i did some test with a couple of events and filters, and it actually seems to work.
let me know what you think, i will write a unit test only if you like this.