public function update(\Eccube\Entity\Plugin $plugin, $path)
{
$pluginBaseDir = null;
$tmp = null;
try {
$this->app->removePluginConfigCache();
Cache::clear($this->app, false);
$tmp = $this->createTempDir();
$this->unpackPluginArchive($path, $tmp);
//一旦テンポラリに展開
$this->checkPluginArchiveContent($tmp);
$config = $this->readYml($tmp . '/' . self::CONFIG_YML);
$event = $this->readYml($tmp . '/event.yml');
if ($plugin->getCode() != $config['code']) {
throw new PluginException('new/old plugin code is different.');
}
if ($plugin->getName() != $config['name']) {
throw new PluginException('new/old plugin name is different.');
}
$pluginBaseDir = $this->calcPluginDir($config['code']);
$this->deleteFile($tmp);
// テンポラリのファイルを削除
$this->unpackPluginArchive($path, $pluginBaseDir);
// 問題なければ本当のplugindirへ
$this->updatePlugin($plugin, $config, $event);
// dbにプラグイン登録
$this->app->writePluginConfigCache();
} catch (PluginException $e) {
foreach (array($tmp) as $dir) {
if (file_exists($dir)) {
$fs = new Filesystem();
$fs->remove($dir);
}
}
throw $e;
}
return true;
}