63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Services\WeldLogTriggers\Contracts;
|
|
|
|
/**
|
|
* Interface for WeldLog triggers
|
|
*
|
|
* Each trigger must implement this interface to be registered
|
|
* in the WeldLogTriggerRegistry and managed by WeldLogTriggerManager
|
|
*/
|
|
interface WeldLogTriggerInterface
|
|
{
|
|
/**
|
|
* Get trigger name for logging purposes
|
|
*
|
|
* @return string The human-readable name of the trigger
|
|
*/
|
|
public function getName(): string;
|
|
|
|
/**
|
|
* Get trigger execution order/priority (1-13)
|
|
* Lower numbers execute first
|
|
*
|
|
* @return int The execution order
|
|
*/
|
|
public function getOrder(): int;
|
|
|
|
/**
|
|
* 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 $weldLogData Current weld log data
|
|
* @param object|null $beforeData Previous weld log 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($weldLogData, $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;
|
|
}
|
|
|