Skip to content

Commit

Permalink
Merge pull request #3707 from nanasess/fix-pluginmanager
Browse files Browse the repository at this point in the history
PluginManager から $app を削除, Abstract メソッド追加
  • Loading branch information
ryo-endo authored Aug 30, 2018
2 parents 3d8ad38 + be02ffc commit ba9b298
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 20 deletions.
66 changes: 54 additions & 12 deletions src/Eccube/Plugin/AbstractPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,64 @@

use Doctrine\DBAL\Migrations\Configuration\Configuration;
use Doctrine\DBAL\Migrations\Migration;
use Symfony\Component\DependencyInjection\ContainerInterface;

class AbstractPluginManager
abstract class AbstractPluginManager
{
const MIGRATION_TABLE_PREFIX = 'migration_';

public function migrationSchema($app, $migrationFilePath, $pluginCode, $version = null)
/**
* Install the plugin.
*
* @param array $meta
* @param ContainerInterface $container
*/
public function install(array $meta, ContainerInterface $container)
{
$config = new Configuration($app['db']);
$config->setMigrationsNamespace('DoctrineMigrations');
$config->setMigrationsDirectory($migrationFilePath);
$config->registerMigrationsFromDirectory($migrationFilePath);
$config->setMigrationsTableName(self::MIGRATION_TABLE_PREFIX.$pluginCode);
$migration = new Migration($config);
$migration->setNoMigrationException(true);
// null 又は 'last' を渡すと最新バージョンまでマイグレートする
// 0か'first'を渡すと最初に戻る
$migration->migrate($version, false);
// quiet.
}

/**
* Update the plugin.
*
* @param array $meta
* @param ContainerInterface $container
*/
public function update(array $meta, ContainerInterface $container)
{
// quiet.
}

/**
* Enable the plugin.
*
* @param array $meta
* @param ContainerInterface $container
*/
public function enable(array $meta, ContainerInterface $container)
{
// quiet.
}

/**
* Disable the plugin.
*
* @param array $meta
* @param ContainerInterface $container
*/
public function disable(array $meta, ContainerInterface $container)
{
// quiet.
}

/**
* Uninstall the plugin.
*
* @param array $meta
* @param ContainerInterface $container
*/
public function uninstall(array $meta, ContainerInterface $container)
{
// quiet.
}
}
9 changes: 1 addition & 8 deletions src/Eccube/Service/PluginService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Eccube\Application;
use Eccube\Common\Constant;
use Eccube\Common\EccubeConfig;
use Eccube\Entity\Plugin;
Expand Down Expand Up @@ -45,11 +44,6 @@ class PluginService
*/
protected $pluginRepository;

/**
* @var Application
*/
protected $app;

/**
* @var EntityProxyService
*/
Expand Down Expand Up @@ -446,8 +440,7 @@ public function callPluginManagerMethod($meta, $method)
if (class_exists($class)) {
$installer = new $class(); // マネージャクラスに所定のメソッドがある場合だけ実行する
if (method_exists($installer, $method)) {
// FIXME appを削除.
$installer->$method($meta, $this->app, $this->container);
$installer->$method($meta, $this->container);
}
}
}
Expand Down

0 comments on commit ba9b298

Please sign in to comment.