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

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

69 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Licensing Service Provider
4 *
5 * @package Forge12\DoubleOptIn\Providers
6 * @since 4.3.0
7 */
8
9 namespace Forge12\DoubleOptIn\Providers;
10
11 use Forge12\DoubleOptIn\Container\BootableProviderInterface;
12 use Forge12\DoubleOptIn\Container\Container;
13 use Forge12\DoubleOptIn\Licensing\AddonLicenseRegistry;
14 use Forge12\DoubleOptIn\Licensing\AddonLicenseRegistryInterface;
15 use Forge12\Shared\LoggerInterface;
16
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit;
19 }
20
21 /**
22 * Class LicensingServiceProvider
23 *
24 * Registers the addon license registry in the container so addons and
25 * license providers can resolve it.
26 *
27 * Binds both the interface and the concrete class to the same singleton
28 * instance. Addons should depend on the interface; license providers may
29 * depend on either.
30 */
31 class LicensingServiceProvider implements BootableProviderInterface {
32
33 /**
34 * {@inheritdoc}
35 */
36 public function register( Container $container ): void {
37 $container->singleton(
38 AddonLicenseRegistry::class,
39 function () use ( $container ) {
40 $registry = AddonLicenseRegistry::getInstance();
41
42 if ( $container->has( LoggerInterface::class ) ) {
43 $registry->setLogger( $container->get( LoggerInterface::class ) );
44 }
45
46 return $registry;
47 }
48 );
49
50 // Alias the interface to the same instance so addons can depend on
51 // the abstraction. Using a factory avoids a circular reference and
52 // resolves through the singleton binding above.
53 $container->singleton(
54 AddonLicenseRegistryInterface::class,
55 function () use ( $container ) {
56 return $container->get( AddonLicenseRegistry::class );
57 }
58 );
59 }
60
61 /**
62 * {@inheritdoc}
63 */
64 public function boot( Container $container ): void {
65 // No runtime wiring is needed at boot: the registry is pure state
66 // populated by license providers at their own boot time.
67 }
68 }
69