Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility set vendor basename #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/Database/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,32 @@ class Migrator {

protected $table_name = 'dbrns_migrations';

/**
* @var string
*/
protected $vendor_basename = 'vendor';

/**
* @param string $command_name
* @param string $vendor_basename
*
* @return Migrator Instance
*/
public static function instance( $command_name = 'dbi') {
public static function instance( $command_name = 'dbi', $vendor_basename = 'vendor') {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Migrator ) ) {
self::$instance = new Migrator();
self::$instance->init( $command_name );
self::$instance->init( $command_name, $vendor_basename );
}

return self::$instance;
}

/**
* @param string $command_name
* @param string $vendor_basename
*/
public function init( $command_name ) {
public function init( $command_name, $vendor_basename ) {
$this->vendor_basename = $vendor_basename;
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );

if ( defined( 'WP_CLI' ) && WP_CLI ) {
Expand Down Expand Up @@ -80,7 +88,7 @@ protected function get_migrations( $exclude = array(), $migration = null, $rollb
$all_migrations = array();

$base_path = __FILE__;
while ( basename( $base_path ) != 'vendor' ) {
while ( basename( $base_path ) != $this->vendor_basename ) {
$base_path = dirname( $base_path );
}

Expand Down