| 1 |
<?php |
| 2 |
/** |
| 3 |
* GDPR Service Provider |
| 4 |
* |
| 5 |
* @package Forge12\DoubleOptIn\Providers |
| 6 |
* @since 3.2.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace Forge12\DoubleOptIn\Providers; |
| 10 |
|
| 11 |
use Forge12\DoubleOptIn\Admin\SingleConsentExportController; |
| 12 |
use Forge12\DoubleOptIn\Container\BootableProviderInterface; |
| 13 |
use Forge12\DoubleOptIn\Container\Container; |
| 14 |
use Forge12\DoubleOptIn\Repository\OptInRepositoryInterface; |
| 15 |
use Forge12\DoubleOptIn\Service\PrivacyIntegration; |
| 16 |
use Forge12\Shared\LoggerInterface; |
| 17 |
|
| 18 |
if ( ! defined( 'ABSPATH' ) ) { |
| 19 |
exit; |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Class GdprServiceProvider |
| 24 |
* |
| 25 |
* Registers all GDPR-related services in the DI container. |
| 26 |
*/ |
| 27 |
class GdprServiceProvider implements BootableProviderInterface { |
| 28 |
|
| 29 |
/** |
| 30 |
* {@inheritdoc} |
| 31 |
*/ |
| 32 |
public function register( Container $container ): void { |
| 33 |
$container->singleton( |
| 34 |
PrivacyIntegration::class, |
| 35 |
function ( Container $c ) { |
| 36 |
return new PrivacyIntegration( |
| 37 |
$c->get( LoggerInterface::class ), |
| 38 |
$c->get( OptInRepositoryInterface::class ) |
| 39 |
); |
| 40 |
} |
| 41 |
); |
| 42 |
|
| 43 |
$container->singleton( |
| 44 |
SingleConsentExportController::class, |
| 45 |
function ( Container $c ) { |
| 46 |
return new SingleConsentExportController( |
| 47 |
$c->get( LoggerInterface::class ), |
| 48 |
$c->get( OptInRepositoryInterface::class ) |
| 49 |
); |
| 50 |
} |
| 51 |
); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* {@inheritdoc} |
| 56 |
*/ |
| 57 |
public function boot( Container $container ): void { |
| 58 |
// Register WordPress Privacy Tools hooks |
| 59 |
$container->get( PrivacyIntegration::class )->register(); |
| 60 |
|
| 61 |
// Register single-record consent export (fallback if Pro is not active) |
| 62 |
$container->get( SingleConsentExportController::class )->registerActions(); |
| 63 |
} |
| 64 |
} |
| 65 |
|