56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Services\LineListTriggers\Contracts;
|
|
|
|
/**
|
|
* Interface for LineList triggers
|
|
*
|
|
* Each trigger must implement this interface to be registered
|
|
* in the LineListTriggerRegistry and managed by LineListTriggerManager
|
|
*/
|
|
interface LineListTriggerInterface
|
|
{
|
|
/**
|
|
* Get trigger name for logging purposes
|
|
*
|
|
* @return string The human-readable name of the trigger
|
|
*/
|
|
public function getName(): string;
|
|
|
|
/**
|
|
* Check if trigger should run based on changed fields
|
|
*
|
|
* @param array $changedFields List of field names that changed
|
|
* @param bool $isNewRecord Whether this is a new record
|
|
* @return bool True if trigger should execute
|
|
*/
|
|
public function shouldRun(array $changedFields, bool $isNewRecord): bool;
|
|
|
|
/**
|
|
* Get fields that this trigger depends on
|
|
* Used to determine if trigger should run when fields change
|
|
*
|
|
* @return array List of field names this trigger depends on
|
|
*/
|
|
public function getDependentFields(): array;
|
|
|
|
/**
|
|
* Execute the trigger logic
|
|
*
|
|
* @param object $lineListData Current line list data
|
|
* @param object|null $beforeData Previous line list data (null for new records)
|
|
* @param array $context Additional context (changed_fields, is_new_record, etc)
|
|
* @return array Result data from trigger execution
|
|
*/
|
|
public function execute($lineListData, $beforeData = null, array $context = []): array;
|
|
|
|
/**
|
|
* Check if trigger can be executed asynchronously (queued)
|
|
*
|
|
* @return bool True if can be queued, false for synchronous execution
|
|
*/
|
|
public function isAsync(): bool;
|
|
}
|
|
|
|
|