| 1 |
<?php |
| 2 |
/** |
| 3 |
* Core Service Provider |
| 4 |
* |
| 5 |
* @package Forge12\DoubleOptIn\Providers |
| 6 |
* @since 4.0.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace Forge12\DoubleOptIn\Providers; |
| 10 |
|
| 11 |
use Forge12\DoubleOptIn\Container\Container; |
| 12 |
use Forge12\DoubleOptIn\Container\BootableProviderInterface; |
| 13 |
use Forge12\Shared\LoggerInterface; |
| 14 |
use Forge12\Shared\Logger; |
| 15 |
|
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
exit; |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Class CoreServiceProvider |
| 22 |
* |
| 23 |
* Registers core services like Logger, TemplateHandler, Messages. |
| 24 |
*/ |
| 25 |
class CoreServiceProvider implements BootableProviderInterface { |
| 26 |
|
| 27 |
/** |
| 28 |
* {@inheritdoc} |
| 29 |
*/ |
| 30 |
public function register( Container $container ): void { |
| 31 |
// Logger |
| 32 |
$container->singleton( |
| 33 |
LoggerInterface::class, |
| 34 |
function () { |
| 35 |
return Logger::getInstance(); |
| 36 |
} |
| 37 |
); |
| 38 |
|
| 39 |
// TemplateHandler |
| 40 |
$container->singleton( |
| 41 |
\forge12\contactform7\CF7DoubleOptIn\TemplateHandler::class, |
| 42 |
function () { |
| 43 |
return \forge12\contactform7\CF7DoubleOptIn\TemplateHandler::getInstance(); |
| 44 |
} |
| 45 |
); |
| 46 |
|
| 47 |
// Messages |
| 48 |
$container->singleton( |
| 49 |
\forge12\contactform7\CF7DoubleOptIn\Messages::class, |
| 50 |
function () { |
| 51 |
return \forge12\contactform7\CF7DoubleOptIn\Messages::getInstance(); |
| 52 |
} |
| 53 |
); |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* {@inheritdoc} |
| 58 |
*/ |
| 59 |
public function boot( Container $container ): void { |
| 60 |
// Initialize logger in container for debugging |
| 61 |
$container->setLogger( $container->get( LoggerInterface::class ) ); |
| 62 |
} |
| 63 |
} |
| 64 |
|