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