• File: MigrationLogServiceProvider.php
  • Full Path: /home/bravrvjk/itiministry.org/wp-content/plugins/give/src/MigrationLog/MigrationLogServiceProvider.php
  • Date Modified: 11/24/2021 4:55 AM
  • File size: 1.2 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace Give\MigrationLog;

use Give\Framework\Migrations\MigrationsRegister;
use Give\Helpers\Hooks;
use Give\MigrationLog\Helpers\Assets;
use Give\MigrationLog\Helpers\Environment;
use Give\MigrationLog\Migrations\CreateMigrationsTable;
use Give\MigrationLog\Migrations\MigrateCompletedMigrations;
use Give\ServiceProviders\ServiceProvider;

/**
 * Class MigrationLogServiceProvider
 * @package Give\MigrationLog
 *
 * @since 2.10.0
 */
class MigrationLogServiceProvider implements ServiceProvider
{
    /**
     * @inheritdoc
     */
    public function register()
    {
        global $wpdb;

        $wpdb->give_migrations = "{$wpdb->prefix}give_migrations";

        give()->singleton(MigrationLogRepository::class);
        give()->singleton(MigrationLogFactory::class);
    }

    /**
     * @inheritdoc
     */
    public function boot()
    {
        give(MigrationsRegister::class)->addMigrations(
            [
                CreateMigrationsTable::class,
                MigrateCompletedMigrations::class,
            ]
        );

        // Hook up
        if (Environment::isMigrationsPage()) {
            Hooks::addAction('admin_enqueue_scripts', Assets::class, 'enqueueScripts');
        }
    }
}