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

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

72 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 * Migration 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\Migration\MigrationFormCompletenessSweep;
14 use Forge12\DoubleOptIn\Migration\MigrationRegistry;
15 use Forge12\Shared\LoggerInterface;
16
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit;
19 }
20
21 /**
22 * Class MigrationServiceProvider
23 *
24 * Registers the MigrationRegistry in the container and schedules the
25 * pending-migration runner on `admin_init` priority 20 (after
26 * `f12_cf7_doubleoptin_register_addons` fires at plugins_loaded:20,
27 * giving addons their chance to register migrations before they run).
28 *
29 * Running only on `admin_init` keeps DDL out of the frontend request
30 * cycle: migrations apply when a site admin visits the admin, which is
31 * the same trigger WordPress core uses for database upgrades.
32 */
33 class MigrationServiceProvider implements BootableProviderInterface {
34
35 /**
36 * {@inheritdoc}
37 */
38 public function register( Container $container ): void {
39 $container->singleton(
40 MigrationRegistry::class,
41 function () use ( $container ) {
42 $registry = MigrationRegistry::getInstance();
43
44 if ( $container->has( LoggerInterface::class ) ) {
45 $registry->setLogger( $container->get( LoggerInterface::class ) );
46 }
47
48 return $registry;
49 }
50 );
51 }
52
53 /**
54 * {@inheritdoc}
55 */
56 public function boot( Container $container ): void {
57 // Register core migrations. Addons register their own migrations
58 // in their own boot() methods — see MigrationInterface docblock.
59 $registry = $container->get( MigrationRegistry::class );
60 $registry->register( new MigrationFormCompletenessSweep() );
61
62 add_action(
63 'admin_init',
64 function () use ( $container ) {
65 $registry = $container->get( MigrationRegistry::class );
66 $registry->runPending();
67 },
68 20
69 );
70 }
71 }
72