* - Plain-text editor: @[7:Display Name] * * @param string $content * @return array Integer agent IDs. */ public function extractMentionIds($content) { $content = (string) $content; if (!$content) { return []; } $ids = []; // Rich editor — span with numeric data-mention-username. if (stripos($content, 'data-mention-username') !== false) { preg_match_all( '/]*\bclass=["\'][^"\']*\bfs_agent_mention\b[^"\']*["\'][^>]*\bdata-mention-username=["\'](\d+)["\'][^>]*>/i', $content, $spanMatches ); foreach ($spanMatches[1] ?? [] as $id) { $ids[] = (int) $id; } } // Plain-text editor — @[agentId:Display Name] token. if (strpos($content, '@[') !== false) { preg_match_all('/@\[(\d+):[^\]]+\]/', $content, $tokenMatches); foreach ($tokenMatches[1] ?? [] as $id) { $ids[] = (int) $id; } } return array_values(array_unique(array_filter($ids))); } }