e040fccba6
- 修改 AbstractProcessNode 中 ProcessContext 的命名空间引用为 app\flow\context\ProcessContext - 引入 app\flow\vo\CanHandleResult 用于节点处理结果表示 - 更新前置策略执行后对成功状态的判断,改为调用 isSuccess() 方法 - 增加日志记录细节,便于调试策略执行中断时的错误信息 - 优化代码注释,提升代码可读性和维护性
42 lines
987 B
PHP
42 lines
987 B
PHP
<?php
|
|
|
|
namespace app\flow\strategies;
|
|
|
|
use app\flow\context\ProcessContext;
|
|
use app\flow\nodes\ProcessNodeInterface;
|
|
|
|
/**
|
|
* 流程策略接口
|
|
* 策略模式的核心接口
|
|
*/
|
|
interface ProcessStrategyInterface
|
|
{
|
|
/**
|
|
* 执行策略
|
|
* @param ProcessContext $context 流程上下文
|
|
* @param ProcessNodeInterface $node 当前节点
|
|
* @return ProcessContext 处理后的上下文
|
|
*/
|
|
public function execute(ProcessContext $context, ProcessNodeInterface $node): ProcessContext;
|
|
|
|
/**
|
|
* 获取策略名称
|
|
* @return string
|
|
*/
|
|
public function getName(): string;
|
|
|
|
/**
|
|
* 获取策略执行阶段
|
|
* @return string 'before' | 'after'
|
|
*/
|
|
public function getPhase(): string;
|
|
|
|
/**
|
|
* 判断策略是否适用
|
|
* @param ProcessContext $context
|
|
* @param ProcessNodeInterface $node
|
|
* @return bool
|
|
*/
|
|
public function isApplicable(ProcessContext $context, ProcessNodeInterface $node): bool;
|
|
}
|