Example Using Pods Migrate to load JSON from a File

Handy method for loading Pods Configuration from the JSON file, includes tests for Migrate Packages component being active.

Provided by @pcfreak30 from Slack

private function _import_packages() {
		pods_init()->setup( $this->_blog );
		pods_init()->load_components();
		pods_components()->get_components();
		pods_components()->load();
		if ( ! class_exists( 'Pods_Migrate_Packages' ) ) {
			$_GET['toggle'] = 1;
			pods_components()->toggle( 'migrate-packages' );
			pods_components()->load();
		}
		if ( ! class_exists( 'Pods_Advanced_Relationships' ) ) {
			$_GET['toggle'] = 1;
			pods_components()->toggle( 'advanced-relationships' );
			pods_components()->load();
		}
		pods_api()->import_package( file_get_contents( Plugin::GetDir( 'pods.json' ) ) );
		pods_api()->save_field( [ 'pod' => 'loans', 'name' => 'company_parent', 'sister_id' => pods_api()->load_field( [ 'pod' => 'company_single', 'name' => 'loans' ] )['id'] ] );
		pods_api()->cache_flush_pods();
		if ( defined( 'PODS_PRELOAD_CONFIG_AFTER_FLUSH' ) && PODS_PRELOAD_CONFIG_AFTER_FLUSH ) {
			pods_api()->load_pods();
		}
	}

Also shows examples of making sure the Pods Migrate Packages Component is loaded prior to attempting to Migrate.

Questions