Skip to content

Commit

Permalink
Pass only updates config to Updater
Browse files Browse the repository at this point in the history
  • Loading branch information
giuscris committed Feb 22, 2025
1 parent d18068a commit 9384129
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
3 changes: 2 additions & 1 deletion formwork/src/Services/Loaders/PanelServiceLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
15 changes: 4 additions & 11 deletions formwork/src/Updater/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<string, mixed>
*/
private array $options = [];

/**
* Updates registry
*/
Expand Down Expand Up @@ -69,12 +61,13 @@ final class Updater
*/
private array $headers;

/**
* @param array<string, mixed> $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() === []) {
Expand Down

0 comments on commit 9384129

Please sign in to comment.