From 9384129f699858599c4e36e81088f127d50005e6 Mon Sep 17 00:00:00 2001 From: Giuseppe Criscione <18699708+giuscris@users.noreply.github.com> Date: Sat, 22 Feb 2025 16:06:35 +0100 Subject: [PATCH] Pass only updates config to `Updater` --- .../src/Services/Loaders/PanelServiceLoader.php | 3 ++- formwork/src/Updater/Updater.php | 15 ++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/formwork/src/Services/Loaders/PanelServiceLoader.php b/formwork/src/Services/Loaders/PanelServiceLoader.php index af3682ee2..de8380055 100644 --- a/formwork/src/Services/Loaders/PanelServiceLoader.php +++ b/formwork/src/Services/Loaders/PanelServiceLoader.php @@ -35,7 +35,8 @@ public function load(Container $container): Panel ->parameter('limit', $this->config->get('system.panel.loginAttempts')) ->parameter('resetTime', $this->config->get('system.panel.loginResetTime')); - $container->define(Updater::class); + $container->define(Updater::class) + ->parameter('options', $this->config->get('system.updates')); $this->request->session()->setDuration($this->config->get('system.panel.sessionTimeout') * 60); diff --git a/formwork/src/Updater/Updater.php b/formwork/src/Updater/Updater.php index 4e00d367b..42f8163fd 100644 --- a/formwork/src/Updater/Updater.php +++ b/formwork/src/Updater/Updater.php @@ -4,7 +4,6 @@ use DateTimeImmutable; use Formwork\Cms\App; -use Formwork\Config\Config; use Formwork\Http\Client; use Formwork\Log\Registry; use Formwork\Parsers\Json; @@ -25,13 +24,6 @@ final class Updater */ private const string API_RELEASE_URI = 'https://api.github.com/repos/' . self::REPOSITORY . '/releases/latest'; - /** - * Updater options - * - * @var array - */ - private array $options = []; - /** * Updates registry */ @@ -69,12 +61,13 @@ final class Updater */ private array $headers; + /** + * @param array $options + */ public function __construct( + private array $options, private App $app, - Config $config, ) { - $this->options = $config->get('system.updates'); - $this->registry = new Registry($this->options['registryFile']); if ($this->registry->toArray() === []) {