Internal Plugin Updater
taufik-nurrohman opened this issue · comments
Taufik Nurrohman commented
We have been too often writing these code in plugin files, look like this is a good time to make it as a standard:
/**
* Plugin Updater
* --------------
*/
Route::accept($config->manager->slug . '/plugin/' . File::B(__DIR__) . '/update', function() use($config, $speak) {
if($request = Request::post()) {
Guardian::checkToken($request['token']);
unset($request['token']); // remove token from request array
File::serialize($request)->saveTo(__DIR__ . DS . 'states' . DS . 'config.txt', 0600);
Notify::success(Config::speak('notify_success_updated', $speak->plugin));
Guardian::kick(File::D($config->url_current));
}
});
<form class="form-plugin" action="<?php echo $config->url_current; ?>/update" method="post">
<?php echo Form::hidden('token', $token); ?>
…
</form>