Admin
11 months ago
Helpers
1 year ago
Migrations
4 years ago
MigrationLogFactory.php
4 years ago
MigrationLogModel.php
4 years ago
MigrationLogRepository.php
1 year ago
MigrationLogServiceProvider.php
4 years ago
MigrationLogStatus.php
1 year ago
MigrationLogServiceProvider.php
52 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\MigrationLog; |
| 4 | |
| 5 | use Give\Framework\Migrations\MigrationsRegister; |
| 6 | use Give\Helpers\Hooks; |
| 7 | use Give\MigrationLog\Helpers\Assets; |
| 8 | use Give\MigrationLog\Helpers\Environment; |
| 9 | use Give\MigrationLog\Migrations\CreateMigrationsTable; |
| 10 | use Give\MigrationLog\Migrations\MigrateCompletedMigrations; |
| 11 | use Give\ServiceProviders\ServiceProvider; |
| 12 | |
| 13 | /** |
| 14 | * Class MigrationLogServiceProvider |
| 15 | * @package Give\MigrationLog |
| 16 | * |
| 17 | * @since 2.10.0 |
| 18 | */ |
| 19 | class MigrationLogServiceProvider implements ServiceProvider |
| 20 | { |
| 21 | /** |
| 22 | * @inheritdoc |
| 23 | */ |
| 24 | public function register() |
| 25 | { |
| 26 | global $wpdb; |
| 27 | |
| 28 | $wpdb->give_migrations = "{$wpdb->prefix}give_migrations"; |
| 29 | |
| 30 | give()->singleton(MigrationLogRepository::class); |
| 31 | give()->singleton(MigrationLogFactory::class); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @inheritdoc |
| 36 | */ |
| 37 | public function boot() |
| 38 | { |
| 39 | give(MigrationsRegister::class)->addMigrations( |
| 40 | [ |
| 41 | CreateMigrationsTable::class, |
| 42 | MigrateCompletedMigrations::class, |
| 43 | ] |
| 44 | ); |
| 45 | |
| 46 | // Hook up |
| 47 | if (Environment::isMigrationsPage()) { |
| 48 | Hooks::addAction('admin_enqueue_scripts', Assets::class, 'enqueueScripts'); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 |