1
0
mirror of https://github.com/flarum/core.git synced 2025-10-10 14:34:30 +02:00

refactoring to support array closures migrations and fixed issues with previous pr for extension rewriting

This commit is contained in:
Daniel Klabbers
2016-02-25 23:25:22 +09:00
committed by Franz Liedke
parent 2b5dab73f9
commit e4412178b1
5 changed files with 60 additions and 49 deletions

View File

@@ -39,7 +39,7 @@ class Extension implements Arrayable
/**
* Unique Id of the extension.
*
* @info Identical to the directory in the extensions directory.
* @info Identical to the directory in the extensions directory.
* @example flarum_suspend
*
* @var string
@@ -222,6 +222,14 @@ class Extension implements Arrayable
return $this->id;
}
/**
* @return string
*/
public function getPath()
{
return $this->path;
}
/**
* Tests whether the extension has assets.
*
@@ -250,11 +258,11 @@ class Extension implements Arrayable
public function toArray()
{
return (array) array_merge([
'id' => $this->getId(),
'version' => $this->getVersion(),
'path' => $this->path,
'icon' => $this->getIcon(),
'hasAssets' => $this->hasAssets(),
'id' => $this->getId(),
'version' => $this->getVersion(),
'path' => $this->path,
'icon' => $this->getIcon(),
'hasAssets' => $this->hasAssets(),
'hasMigrations' => $this->hasMigrations(),
], $this->composerJson);
}

View File

@@ -182,7 +182,7 @@ class ExtensionManager
{
if ($extension->hasAssets()) {
$this->filesystem->copyDirectory(
$this->app->basePath() . '/extensions/' . $extension->getId() . '/assets',
$extension->getPath() . '/assets',
$this->app->basePath() . '/assets/extensions/' . $extension->getId()
);
}
@@ -219,7 +219,7 @@ class ExtensionManager
public function migrate(Extension $extension, $up = true)
{
if ($extension->hasMigrations()) {
$migrationDir = public_path('extensions/' . $extension->getId() . '/migrations');
$migrationDir = $extension->getPath() . '/migrations';
$this->app->bind('Illuminate\Database\Schema\Builder', function ($container) {
return $container->make('Illuminate\Database\ConnectionInterface')->getSchemaBuilder();
@@ -240,7 +240,7 @@ class ExtensionManager
*/
public function migrateDown(Extension $extension)
{
$this->migrate($extension->getId(), false);
$this->migrate($extension, false);
}
public function getMigrator()