| 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\Audit\ConsentAuditListener; |
| 14 |
use Forge12\DoubleOptIn\Container\Container; |
| 15 |
use Forge12\DoubleOptIn\EventSystem\EventDispatcherInterface; |
| 16 |
use Forge12\DoubleOptIn\Repository\OptInRepositoryInterface; |
| 17 |
use Forge12\DoubleOptIn\Service\PrivacyIntegration; |
| 18 |
use Forge12\Shared\LoggerInterface; |
| 19 |
|
| 20 |
if ( ! defined( 'ABSPATH' ) ) { |
| 21 |
exit; |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Class GdprServiceProvider |
| 26 |
* |
| 27 |
* Registers all GDPR-related services in the DI container. |
| 28 |
*/ |
| 29 |
class GdprServiceProvider implements BootableProviderInterface { |
| 30 |
|
| 31 |
/** |
| 32 |
* {@inheritdoc} |
| 33 |
*/ |
| 34 |
public function register( Container $container ): void { |
| 35 |
$container->singleton( |
| 36 |
PrivacyIntegration::class, |
| 37 |
function ( Container $c ) { |
| 38 |
return new PrivacyIntegration( |
| 39 |
$c->get( LoggerInterface::class ), |
| 40 |
$c->get( OptInRepositoryInterface::class ), |
| 41 |
// Bound by MailStatusServiceProvider (5.8.0); resolved lazily. |
| 42 |
$c->get( \Forge12\DoubleOptIn\Repository\OptInMailStatusRepository::class ) |
| 43 |
); |
| 44 |
} |
| 45 |
); |
| 46 |
|
| 47 |
$container->singleton( |
| 48 |
SingleConsentExportController::class, |
| 49 |
function ( Container $c ) { |
| 50 |
return new SingleConsentExportController( |
| 51 |
$c->get( LoggerInterface::class ), |
| 52 |
$c->get( OptInRepositoryInterface::class ) |
| 53 |
); |
| 54 |
} |
| 55 |
); |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* {@inheritdoc} |
| 60 |
*/ |
| 61 |
public function boot( Container $container ): void { |
| 62 |
// Register WordPress Privacy Tools hooks |
| 63 |
$container->get( PrivacyIntegration::class )->register(); |
| 64 |
|
| 65 |
// Register single-record consent export (fallback if Pro is not active) |
| 66 |
$container->get( SingleConsentExportController::class )->registerActions(); |
| 67 |
|
| 68 |
// A renewed consent is its own audit entry (5.8.0). |
| 69 |
if ( $container->has( EventDispatcherInterface::class ) ) { |
| 70 |
( new ConsentAuditListener() )->register( $container->get( EventDispatcherInterface::class ) ); |
| 71 |
} |
| 72 |
} |
| 73 |
} |
| 74 |
|