notices()->register_provider( new NoticeProvider() ); // wp-kit syncs db_version_to_current after a successful upgrade via // this hook subscription; without it the option may lag behind a // plugin-version bump that ships no new migrations. $hooks = new MigrationHooks( $this->get_manager(), self::PREFIX ); $hooks->register(); add_action( 'rest_api_init', [ $this, 'register_rest_routes' ] ); } /** * Lazily build the migration manager. * * @return MigrationManager */ public function get_manager(): MigrationManager { if ( null === $this->manager ) { $registry = new MigrationRegistry( TextyMigration::get_db_version_key(), TEXTY_VERSION ); $registry->register_many( $this->get_migrations() ); $this->manager = new MigrationManager( $registry, self::PREFIX ); } return $this->manager; } /** * Whether any migration is pending. * * @return bool */ public function is_upgrade_required(): bool { return $this->get_manager()->is_upgrade_required(); } /** * Register the wp-kit migration REST controller. * * @return void */ public function register_rest_routes(): void { $migrations = new MigrationRESTController( $this->get_manager(), self::REST_NAMESPACE ); $migrations->register_routes(); } /** * Map of version → migration class. Add new entries in ascending order * as the schema evolves; wp-kit sorts by version_compare before running. * * @return array */ protected function get_migrations(): array { return [ '2.0.0' => V_2_0_0::class, ]; } }