1. Go to this page and download the library: Download jeyroik/df-triggers library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jeyroik / df-triggers example snippets
// get income request with specified instance id and event name
// get instance by instance id
// @var IInstance $instance
use deflou\components\triggers\TriggerService;
$resolvedEvent = $instance->buildResolver()->resolveEvent();
$triggerService = new TriggerService();
$triggers = $triggerService->getTriggers($instance->getId(), $eventName, ['vendorName1', 'vendorName2, ...']);
foreach ($triggers as $trigger) {
if ($triggerService->isApplicableTrigger($resolvedEvent, $trigger)) {
$result = $trigger->getInstance(ETrigger::Operation)->buildResolver()->resolveOperation($resolvedEvent, $trigger)->run();
if ($result->isSuccess()) {
echo 'Success trigger #' . $trigger->getId() . ' execution';
} else {
echo 'Failed trigger #' . $trigger->getId() . ' execution';
}
}
}