make_key( $resolver->get_tool_key() ); $this->resolvers[ $key ] = $resolver; } } /** * Resolve all sanitized mentions into context strings. * * @param array $mentions Sanitized mention list. * @return string Concatenated non-empty context blocks separated by newlines. */ public function resolve_all( array $mentions ): string { $blocks = []; foreach ( $mentions as $mention ) { $key = $this->make_key( $mention ); if ( ! isset( $this->resolvers[ $key ] ) ) { continue; } $block = $this->resolvers[ $key ]->resolve( $mention ); if ( ! empty( $block ) ) { $blocks[] = $block; } } return implode( "\n\n", $blocks ); } /** * Build a registry key from plugin + name. * * @param array $data Array with 'plugin' and 'name' keys. * @return string */ private function make_key( array $data ): string { return ( $data['plugin'] ?? '' ) . ':' . ( $data['name'] ?? '' ); } }