File "InstallerProvider.php"

Full Path: /home/warrior1/public_html/plugins/file-manager/backend/app/Providers/InstallerProvider.php
File size: 2 KB
MIME-type: text/x-php
Charset: utf-8

<?php

namespace BitApps\FM\Providers;

use BitApps\FM\Config;
use BitApps\WPDatabase\Connection;
use BitApps\WPKit\Installer;

class InstallerProvider
{
    private $_activateHook;

    private static $_uninstallHook;

    public function __construct()
    {
        $this->_activateHook   = Config::withPrefix('activate');
        self::$_uninstallHook  = Config::withPrefix('uninstall');
    }

    public function register()
    {
        $installer = new Installer(
            [
                'php'        => Config::REQUIRED_PHP_VERSION,
                'wp'         => Config::REQUIRED_WP_VERSION,
                'version'    => Config::VERSION,
                'oldVersion' => Config::getOption('version', '0.0'),
                'multisite'  => false,
                'basename'   => Config::get('BASENAME'),
            ],
            [
                'activate'  => $this->_activateHook,
                'uninstall' => self::$_uninstallHook,
            ],
            [

                'migration' => $this->migration(),
                'drop'      => $this->drop(),
            ]
        );
        $installer->register();
    }

    public static function migration()
    {
        $migrations = [
            'BFMLogsTableMigration',
            'BFMPluginOptions',
        ];

        return [
            'path'       => Config::get('BACKEND_DIR')
                . DIRECTORY_SEPARATOR
                . 'db'
                . DIRECTORY_SEPARATOR
                . 'Migrations'
                . DIRECTORY_SEPARATOR,
            'migrations' => $migrations,
        ];
    }

    public static function drop()
    {
        $migrations = [
            'BFMLogsTableMigration',
            'BFMPluginOptions',
        ];

        return [
            'path'       => Config::get('BACKEND_DIR')
                . DIRECTORY_SEPARATOR
                . 'db'
                . DIRECTORY_SEPARATOR
                . 'Migrations'
                . DIRECTORY_SEPARATOR,
            'migrations' => $migrations,
        ];
    }
}