Files
tcpserver-flow/app/flow/nodes/ProcessNodeInterface.php
T

70 lines
1.6 KiB
PHP

<?php
namespace app\flow\nodes;
use app\flow\context\ProcessContext;
use app\flow\context\bean\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;
public function getChildNodes(): array;
public function getChildNodeCount(): int;
/**
* 获取节点名称
* @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;
}