| 1 |
<?php |
| 2 |
/** |
| 3 |
* Setup Wizard Service Provider |
| 4 |
* |
| 5 |
* @package Forge12\DoubleOptIn\Providers |
| 6 |
* @since 5.7.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
declare( strict_types=1 ); |
| 10 |
|
| 11 |
namespace Forge12\DoubleOptIn\Providers; |
| 12 |
|
| 13 |
use Forge12\DoubleOptIn\Container\BootableProviderInterface; |
| 14 |
use Forge12\DoubleOptIn\Container\Container; |
| 15 |
use Forge12\DoubleOptIn\FormSettings\FormSettingsService; |
| 16 |
use Forge12\DoubleOptIn\Setup\FormDefaults; |
| 17 |
use Forge12\DoubleOptIn\Setup\FormPluginDetector; |
| 18 |
use Forge12\DoubleOptIn\Setup\SetupMailComposer; |
| 19 |
use Forge12\DoubleOptIn\Setup\SetupRedirect; |
| 20 |
use Forge12\DoubleOptIn\Setup\SetupRestController; |
| 21 |
use Forge12\DoubleOptIn\Setup\SetupService; |
| 22 |
use Forge12\DoubleOptIn\Setup\SetupState; |
| 23 |
|
| 24 |
if ( ! defined( 'ABSPATH' ) ) { |
| 25 |
exit; |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Registers the setup wizard: state, REST routes, activation redirect and |
| 30 |
* the sender defaults it stores. |
| 31 |
*/ |
| 32 |
class SetupServiceProvider implements BootableProviderInterface { |
| 33 |
|
| 34 |
/** |
| 35 |
* {@inheritdoc} |
| 36 |
*/ |
| 37 |
public function register( Container $container ): void { |
| 38 |
$container->singleton( |
| 39 |
SetupState::class, |
| 40 |
static function () { |
| 41 |
return new SetupState(); |
| 42 |
} |
| 43 |
); |
| 44 |
$container->singleton( |
| 45 |
FormPluginDetector::class, |
| 46 |
static function () { |
| 47 |
return new FormPluginDetector(); |
| 48 |
} |
| 49 |
); |
| 50 |
$container->singleton( |
| 51 |
SetupService::class, |
| 52 |
static function ( Container $c ) { |
| 53 |
return new SetupService( |
| 54 |
$c->get( SetupState::class ), |
| 55 |
$c->get( FormSettingsService::class ), |
| 56 |
$c->get( FormPluginDetector::class ), |
| 57 |
new SetupMailComposer() |
| 58 |
); |
| 59 |
} |
| 60 |
); |
| 61 |
$container->singleton( |
| 62 |
SetupRestController::class, |
| 63 |
static function ( Container $c ) { |
| 64 |
return new SetupRestController( |
| 65 |
$c->get( SetupService::class ), |
| 66 |
$c->get( SetupState::class ) |
| 67 |
); |
| 68 |
} |
| 69 |
); |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* {@inheritdoc} |
| 74 |
*/ |
| 75 |
public function boot( Container $container ): void { |
| 76 |
$container->get( SetupRestController::class )->init(); |
| 77 |
SetupRedirect::register(); |
| 78 |
FormDefaults::register(); |
| 79 |
} |
| 80 |
} |
| 81 |
|