- 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.
42 lines
909 B
PHP
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 ];
|
|
}
|
|
}
|