| 1 |
<?php |
| 2 |
/** |
| 3 |
* Repository 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\ServiceProviderInterface; |
| 13 |
use Forge12\DoubleOptIn\Repository\OptInRepository; |
| 14 |
use Forge12\DoubleOptIn\Repository\OptInRepositoryInterface; |
| 15 |
use Forge12\DoubleOptIn\Service\OptInLinkGenerator; |
| 16 |
use Forge12\DoubleOptIn\Service\OptInValidator; |
| 17 |
use Forge12\Shared\LoggerInterface; |
| 18 |
|
| 19 |
if ( ! defined( 'ABSPATH' ) ) { |
| 20 |
exit; |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Class RepositoryServiceProvider |
| 25 |
* |
| 26 |
* Registers repository and service bindings. |
| 27 |
*/ |
| 28 |
class RepositoryServiceProvider implements ServiceProviderInterface { |
| 29 |
|
| 30 |
/** |
| 31 |
* {@inheritdoc} |
| 32 |
*/ |
| 33 |
public function register( Container $container ): void { |
| 34 |
// OptIn Repository |
| 35 |
$container->singleton( |
| 36 |
OptInRepositoryInterface::class, |
| 37 |
function ( Container $c ) { |
| 38 |
global $wpdb; |
| 39 |
return new OptInRepository( |
| 40 |
$wpdb, |
| 41 |
$c->get( LoggerInterface::class ) |
| 42 |
); |
| 43 |
} |
| 44 |
); |
| 45 |
|
| 46 |
// OptIn Link Generator |
| 47 |
$container->singleton( |
| 48 |
OptInLinkGenerator::class, |
| 49 |
function () { |
| 50 |
return new OptInLinkGenerator(); |
| 51 |
} |
| 52 |
); |
| 53 |
|
| 54 |
// OptIn Validator |
| 55 |
$container->singleton( |
| 56 |
OptInValidator::class, |
| 57 |
function ( Container $c ) { |
| 58 |
return new OptInValidator( |
| 59 |
$c->get( LoggerInterface::class ) |
| 60 |
); |
| 61 |
} |
| 62 |
); |
| 63 |
} |
| 64 |
} |
| 65 |
|