PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.5.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.5.0
5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.51 3.0.60 3.0.61 3.0.62 3.0.70 3.0.71 3.0.72 3.1.0 All 34 releases
double-opt-in / src / Providers / FormSettingsServiceProvider.php

FormSettingsServiceProvider.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 5.5.0, at src/Providers/FormSettingsServiceProvider.php

88 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Form Settings Service Provider
4 *
5 * @package Forge12\DoubleOptIn\Providers
6 * @since 4.1.0
7 */
8
9 namespace Forge12\DoubleOptIn\Providers;
10
11 use Forge12\DoubleOptIn\Admin\FormSettingsController;
12 use Forge12\DoubleOptIn\Container\BootableProviderInterface;
13 use Forge12\DoubleOptIn\Container\Container;
14 use Forge12\DoubleOptIn\FormSettings\FormSettingsDTO;
15 use Forge12\DoubleOptIn\FormSettings\FormSettingsService;
16 use Forge12\DoubleOptIn\FormSettings\FormSettingsValidator;
17 use Forge12\DoubleOptIn\Integration\FormIntegrationRegistry;
18 use Forge12\Shared\LoggerInterface;
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit;
22 }
23
24 /**
25 * Class FormSettingsServiceProvider
26 *
27 * Registers form settings services in the DI container.
28 */
29 class FormSettingsServiceProvider implements BootableProviderInterface {
30
31 /**
32 * Register services in the container.
33 *
34 * @param Container $container The DI container.
35 *
36 * @return void
37 */
38 public function register( Container $container ): void {
39 // Register validator as singleton
40 $container->singleton(
41 FormSettingsValidator::class,
42 function () {
43 return new FormSettingsValidator();
44 }
45 );
46
47 // Register service as singleton
48 $container->singleton(
49 FormSettingsService::class,
50 function ( Container $c ) {
51 return new FormSettingsService(
52 $c->get( LoggerInterface::class ),
53 FormIntegrationRegistry::getInstance(),
54 $c->get( FormSettingsValidator::class )
55 );
56 }
57 );
58
59 // Register controller as singleton
60 $container->singleton(
61 FormSettingsController::class,
62 function ( Container $c ) {
63 return new FormSettingsController(
64 $c->get( LoggerInterface::class ),
65 $c->get( FormSettingsService::class ),
66 $c->get( FormSettingsValidator::class )
67 );
68 }
69 );
70 }
71
72 /**
73 * Boot services.
74 *
75 * @param Container $container The DI container.
76 *
77 * @return void
78 */
79 public function boot( Container $container ): void {
80 // Register AJAX actions
81 $controller = $container->get( FormSettingsController::class );
82 $controller->registerActions();
83
84 // The forms admin screen is the React SPA (AdminPageController), which
85 // consumes this controller's REST routes.
86 }
87 }
88