e040fccba6
- 修改 AbstractProcessNode 中 ProcessContext 的命名空间引用为 app\flow\context\ProcessContext - 引入 app\flow\vo\CanHandleResult 用于节点处理结果表示 - 更新前置策略执行后对成功状态的判断,改为调用 isSuccess() 方法 - 增加日志记录细节,便于调试策略执行中断时的错误信息 - 优化代码注释,提升代码可读性和维护性
66 lines
1.5 KiB
PHP
66 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace app\flow\nodes;
|
|
|
|
use app\flow\context\ProcessContext;
|
|
use app\flow\vo\CanHandleResult;
|
|
|
|
/**
|
|
* 流程节点接口
|
|
* 责任链模式的核心接口
|
|
*/
|
|
interface ProcessNodeInterface
|
|
{
|
|
/**
|
|
* 设置下一个节点
|
|
* @param ProcessNodeInterface $next 下一个处理节点
|
|
* @return ProcessNodeInterface 返回自身,支持链式调用
|
|
*/
|
|
public function setNext(ProcessNodeInterface $next): ProcessNodeInterface;
|
|
|
|
/**
|
|
* 获取下一个节点
|
|
* @return ProcessNodeInterface|null
|
|
*/
|
|
public function getNext(): ?ProcessNodeInterface;
|
|
|
|
/**
|
|
* 处理流程
|
|
* @param ProcessContext $context 流程上下文
|
|
* @return ProcessContext 处理后的上下文
|
|
*/
|
|
public function handle(ProcessContext $context): ProcessContext;
|
|
|
|
/**
|
|
* 获取节点名称
|
|
* @return string
|
|
*/
|
|
public static function getName(): string;
|
|
|
|
/**
|
|
* 获取节点编码
|
|
* @return string
|
|
*/
|
|
public function getCode(): string;
|
|
|
|
/**
|
|
* 判断当前节点是否能处理该步骤
|
|
* @param ProcessContext $context
|
|
* @return CanHandleResult 包含是否能处理以及期望下一步的结果
|
|
*/
|
|
public function canHandle(ProcessContext $context): CanHandleResult;
|
|
|
|
/**
|
|
* 是否启用该节点
|
|
* @return bool
|
|
*/
|
|
public function isEnabled(): bool;
|
|
|
|
/**
|
|
* 设置是否启用
|
|
* @param bool $enabled
|
|
* @return ProcessNodeInterface
|
|
*/
|
|
public function setEnabled(bool $enabled): ProcessNodeInterface;
|
|
}
|