mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 16:02:44 +08:00
Re-run update check after update operations
This commit is contained in:
parent
3497028cc0
commit
fd70b46c91
|
@ -55,12 +55,8 @@ class GlobalUpdateHandler
|
|||
throw new ComposerUpdateFailedException('*', $output->getContents());
|
||||
}
|
||||
|
||||
$this->commandDispatcher->dispatch(
|
||||
new CheckForUpdates($command->actor)
|
||||
);
|
||||
|
||||
$this->events->dispatch(
|
||||
new FlarumUpdated(FlarumUpdated::GLOBAL)
|
||||
new FlarumUpdated($command->actor, FlarumUpdated::GLOBAL)
|
||||
);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -84,10 +84,8 @@ class MajorUpdateHandler
|
|||
return true;
|
||||
}
|
||||
|
||||
$this->lastUpdateCheck->forgetAll();
|
||||
|
||||
$this->events->dispatch(
|
||||
new FlarumUpdated(FlarumUpdated::MAJOR)
|
||||
new FlarumUpdated($command->actor, FlarumUpdated::MAJOR)
|
||||
);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -68,10 +68,8 @@ class MinorUpdateHandler
|
|||
throw new ComposerUpdateFailedException('flarum/*', $output->getContents());
|
||||
}
|
||||
|
||||
$this->lastUpdateCheck->forgetAll();
|
||||
|
||||
$this->events->dispatch(
|
||||
new FlarumUpdated(FlarumUpdated::MINOR)
|
||||
new FlarumUpdated($command->actor, FlarumUpdated::MINOR)
|
||||
);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -9,19 +9,27 @@
|
|||
|
||||
namespace Flarum\PackageManager\Event;
|
||||
|
||||
use Flarum\User\User;
|
||||
|
||||
class FlarumUpdated
|
||||
{
|
||||
public const GLOBAL = 'global';
|
||||
public const MAJOR = 'major';
|
||||
public const MINOR = 'minor';
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
public $actor;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
public function __construct(string $type)
|
||||
public function __construct(User $actor, string $type)
|
||||
{
|
||||
$this->actor = $actor;
|
||||
$this->type = $type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,9 +79,4 @@ class LastUpdateCheck
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function forgetAll(): void
|
||||
{
|
||||
$this->save([]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,13 +10,15 @@
|
|||
namespace Flarum\PackageManager\Listener;
|
||||
|
||||
use Composer\Command\ClearCacheCommand;
|
||||
use Flarum\Bus\Dispatcher;
|
||||
use Flarum\Database\Console\MigrateCommand;
|
||||
use Flarum\Foundation\Console\AssetsPublishCommand;
|
||||
use Flarum\PackageManager\Command\CheckForUpdates;
|
||||
use Flarum\PackageManager\Event\FlarumUpdated;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
|
||||
class PostUpdateListener
|
||||
class FlarumUpdateListener
|
||||
{
|
||||
/**
|
||||
* @var ClearCacheCommand
|
||||
|
@ -33,11 +35,23 @@ class PostUpdateListener
|
|||
*/
|
||||
private $migrate;
|
||||
|
||||
public function __construct(ClearCacheCommand $clearCache, AssetsPublishCommand $publishAssets, MigrateCommand $migrate)
|
||||
/**
|
||||
* @var Dispatcher
|
||||
*/
|
||||
private $bus;
|
||||
|
||||
/**
|
||||
* @param ClearCacheCommand $clearCache
|
||||
* @param AssetsPublishCommand $publishAssets
|
||||
* @param MigrateCommand $migrate
|
||||
* @param Dispatcher $bus
|
||||
*/
|
||||
public function __construct(ClearCacheCommand $clearCache, AssetsPublishCommand $publishAssets, MigrateCommand $migrate, Dispatcher $bus)
|
||||
{
|
||||
$this->clearCache = $clearCache;
|
||||
$this->publishAssets = $publishAssets;
|
||||
$this->migrate = $migrate;
|
||||
$this->bus = $bus;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,5 +62,9 @@ class PostUpdateListener
|
|||
$this->clearCache->run(new ArrayInput([]), new NullOutput());
|
||||
$this->migrate->run(new ArrayInput([]), new NullOutput());
|
||||
$this->publishAssets->run(new ArrayInput([]), new NullOutput());
|
||||
|
||||
$this->bus->dispatch(
|
||||
new CheckForUpdates($event->actor)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ use Monolog\Handler\RotatingFileHandler;
|
|||
use Monolog\Logger;
|
||||
use Flarum\PackageManager\Event\FlarumUpdated;
|
||||
use Flarum\PackageManager\Extension\Event\Updated;
|
||||
use Flarum\PackageManager\Listener\PostUpdateListener;
|
||||
use Flarum\PackageManager\Listener\FlarumUpdateListener;
|
||||
|
||||
class PackageManagerServiceProvider extends AbstractServiceProvider
|
||||
{
|
||||
|
@ -89,6 +89,6 @@ class PackageManagerServiceProvider extends AbstractServiceProvider
|
|||
}
|
||||
);
|
||||
|
||||
$events->listen(FlarumUpdated::class, PostUpdateListener::class);
|
||||
$events->listen(FlarumUpdated::class, FlarumUpdateListener::class);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user