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 / EventServiceProvider.php

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

79 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Event 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\BootableProviderInterface;
13 use Forge12\DoubleOptIn\EventSystem\EventDispatcher;
14 use Forge12\DoubleOptIn\EventSystem\EventDispatcherInterface;
15 use Forge12\DoubleOptIn\Bridge\WordPressHookBridge;
16 use Forge12\Shared\LoggerInterface;
17
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit;
20 }
21
22 /**
23 * Class EventServiceProvider
24 *
25 * Registers the event dispatcher and sets up event listeners.
26 */
27 class EventServiceProvider implements BootableProviderInterface {
28
29 /**
30 * {@inheritdoc}
31 */
32 public function register( Container $container ): void {
33 // Event Dispatcher
34 $container->singleton(
35 EventDispatcherInterface::class,
36 function ( Container $c ) {
37 return new EventDispatcher(
38 $c->get( LoggerInterface::class ),
39 true // Bridge to WordPress hooks for BC
40 );
41 }
42 );
43
44 // WordPress Hook Bridge
45 $container->singleton(
46 WordPressHookBridge::class,
47 function ( Container $c ) {
48 return new WordPressHookBridge(
49 $c->get( EventDispatcherInterface::class ),
50 $c->get( LoggerInterface::class )
51 );
52 }
53 );
54 }
55
56 /**
57 * {@inheritdoc}
58 */
59 public function boot( Container $container ): void {
60 $dispatcher = $container->get( EventDispatcherInterface::class );
61
62 // Initialize the WordPress Hook Bridge
63 $hookBridge = $container->get( WordPressHookBridge::class );
64 $hookBridge->registerBridges();
65
66 /**
67 * Action: f12_cf7_doubleoptin_register_event_listeners
68 *
69 * Allows external code to register event listeners.
70 *
71 * @param EventDispatcherInterface $dispatcher The event dispatcher.
72 * @param WordPressHookBridge $hookBridge The hook bridge for BC.
73 *
74 * @since 4.0.0
75 */
76 do_action( 'f12_cf7_doubleoptin_register_event_listeners', $dispatcher, $hookBridge );
77 }
78 }
79