config = array_merge($this->config, $config); } /** * 执行策略 */ public function execute(ProcessContext $context, ProcessNodeInterface $node): ProcessContext { if (!$this->isApplicable($context, $node)) { return $context; } return $this->doExecute($context, $node); } /** * 具体执行逻辑,由子类实现 */ abstract protected function doExecute(ProcessContext $context, ProcessNodeInterface $node): ProcessContext; /** * 获取策略执行阶段 */ public function getPhase(): string { return $this->phase; } /** * 设置执行阶段 */ public function setPhase(string $phase): self { $this->phase = $phase; return $this; } /** * 判断策略是否适用 * 默认总是适用 */ public function isApplicable(ProcessContext $context, ProcessNodeInterface $node): bool { return true; } /** * 获取配置 */ protected function getConfig(string $key, mixed $default = null): mixed { return $this->config[$key] ?? $default; } }