mirror of
https://github.com/flarum/framework.git
synced 2025-03-10 12:21:11 +08:00
Fix generate:migration command for extensions
Apparently, this code was from back when we had a special "extensions" directory for Composer packages marked as Flarum extensions. While we're at it, we now inject the Paths instance instead of using one of the global helpers (which I am trying to get rid of). Refs #2055.
This commit is contained in:
parent
9bcfc4fafd
commit
814013ba48
@ -9,7 +9,7 @@
|
||||
|
||||
namespace Flarum\Database;
|
||||
|
||||
use Flarum\Extension\Extension;
|
||||
use Flarum\Foundation\Paths;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
class MigrationCreator
|
||||
@ -22,27 +22,28 @@ class MigrationCreator
|
||||
protected $files;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @var Paths
|
||||
*/
|
||||
protected $publicPath;
|
||||
protected $paths;
|
||||
|
||||
/**
|
||||
* Create a new migrator instance.
|
||||
*
|
||||
* @param Filesystem $files
|
||||
* @param string $publicPath
|
||||
* @param Paths $paths
|
||||
*/
|
||||
public function __construct(Filesystem $files, $publicPath)
|
||||
public function __construct(Filesystem $files, Paths $paths)
|
||||
{
|
||||
$this->files = $files;
|
||||
$this->publicPath = $publicPath;
|
||||
$this->paths = $paths;
|
||||
#
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new migration for the given extension.
|
||||
*
|
||||
* @param string $name
|
||||
* @param Extension $extension
|
||||
* @param string $extension
|
||||
* @param string $table
|
||||
* @param bool $create
|
||||
* @return string
|
||||
@ -105,9 +106,11 @@ class MigrationCreator
|
||||
*/
|
||||
protected function getMigrationPath($extension)
|
||||
{
|
||||
$parent = $extension ? public_path('extensions/'.$extension) : __DIR__.'/../..';
|
||||
|
||||
return $parent.'/migrations';
|
||||
if ($extension) {
|
||||
return $this->paths->vendor.'/'.$extension.'/migrations';
|
||||
} else {
|
||||
return __DIR__.'/../../migrations';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,12 +23,5 @@ class MigrationServiceProvider extends AbstractServiceProvider
|
||||
$this->app->singleton(MigrationRepositoryInterface::class, function ($app) {
|
||||
return new DatabaseMigrationRepository($app['flarum.db'], 'migrations');
|
||||
});
|
||||
|
||||
$this->app->bind(MigrationCreator::class, function () {
|
||||
return new MigrationCreator(
|
||||
$this->app->make(Filesystem::class),
|
||||
$this->app->make(Paths::class)->base
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user