Files
siti-ai-product-content-gen…/includes/Core/class-groq-ai-service-container.php
Roberto Guagliardo 5171f93a93 Add Google and Groq AI providers, enhance provider manager, and implement conversation and logging services
- Introduced `Groq_AI_Provider_Google` and `Groq_AI_Provider_Groq` classes for handling AI interactions with Google and Groq respectively.
- Enhanced `Groq_AI_Provider_Manager` to register and manage multiple AI providers.
- Implemented `Groq_AI_Conversation_Manager` for managing conversation IDs and context hashes.
- Added `Groq_AI_Generation_Logger` for logging AI generation events and managing log tables.
- Developed `Groq_AI_Prompt_Builder` for constructing prompts and processing AI responses.
- Established `Groq_AI_Settings_Manager` for managing plugin settings, including context fields and module configurations.
2025-12-05 23:58:15 +01:00

42 lines
909 B
PHP

<?php
/**
* Lightweight container voor Groq AI plugin services.
*
* Doel:
* - Centraliseren van service creatie en dependency sharing.
* - Mogelijke vervanging voor de huidige singleton/inline instanties in groq-ai-product-text.php.
*/
class Groq_AI_Service_Container {
/** @var array<string,mixed> */
private $services = [];
/**
* Registreer een service factory.
*
* @param string $key
* @param callable $factory
*/
public function set( $key, callable $factory ) {
$this->services[ $key ] = $factory;
}
/**
* Haal een service op en initialiseer deze lazy.
*
* @param string $key
* @return mixed
*/
public function get( $key ) {
if ( ! isset( $this->services[ $key ] ) ) {
return null;
}
if ( is_callable( $this->services[ $key ] ) ) {
$this->services[ $key ] = call_user_func( $this->services[ $key ], $this );
}
return $this->services[ $key ];
}
}