<?php
 namespace App\Services\Communication; use App\Core\Hook\HookManager; class HookCommunicationBridge { public function __construct( private HookManager $hooks, private CommunicationEventMapper $mapper, ) {} public function register(): void { foreach (config('communication_events.hooks', []) as $hookName => $mappings) { if (! is_string($hookName) || ! is_array($mappings) || $mappings === []) { continue; } $this->hooks->listenAction($hookName, function (array $context) use ($mappings): void { foreach ($mappings as $mapping) { if (! is_array($mapping)) { continue; } $communicationEvent = $this->mapper->mapFromHookContext($mapping, $context); if ($communicationEvent !== null) { event($communicationEvent); } } }); } } } 