Merge pull request #825 from Zankaria/context-fix

context.php: fix missing include file
This commit is contained in:
Lorenzo Yario 2024-10-20 12:03:51 -07:00 committed by GitHub
commit d6677bb90c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,8 +1,7 @@
<?php <?php
namespace Vichan; namespace Vichan;
use RuntimeException; use Vichan\Data\Driver\{CacheDriver, HttpDriver, ErrorLogLogDriver, FileLogDriver, LogDriver, StderrLogDriver, SyslogLogDriver};
use Vichan\Data\Driver\{HttpDriver, ErrorLogLogDriver, FileLogDriver, LogDriver, StderrLogDriver, SyslogLogDriver};
use Vichan\Service\HCaptchaQuery; use Vichan\Service\HCaptchaQuery;
use Vichan\Service\NativeCaptchaQuery; use Vichan\Service\NativeCaptchaQuery;
use Vichan\Service\ReCaptchaQuery; use Vichan\Service\ReCaptchaQuery;
@ -19,7 +18,7 @@ class Context {
public function get(string $name): mixed { public function get(string $name): mixed {
if (!isset($this->definitions[$name])) { if (!isset($this->definitions[$name])) {
throw new RuntimeException("Could not find a dependency named $name"); throw new \RuntimeException("Could not find a dependency named $name");
} }
$ret = $this->definitions[$name]; $ret = $this->definitions[$name];
@ -69,13 +68,13 @@ function build_context(array $config): Context {
$config['captcha']['hcaptcha']['sitekey'] $config['captcha']['hcaptcha']['sitekey']
); );
default: default:
throw new RuntimeException('No remote captcha service available'); throw new \RuntimeException('No remote captcha service available');
} }
}, },
NativeCaptchaQuery::class => function($c) { NativeCaptchaQuery::class => function($c) {
$config = $c->get('config'); $config = $c->get('config');
if ($config['captcha']['provider'] !== 'native') { if ($config['captcha']['provider'] !== 'native') {
throw new RuntimeException('No native captcha service available'); throw new \RuntimeException('No native captcha service available');
} }
return new NativeCaptchaQuery( return new NativeCaptchaQuery(
$c->get(HttpDriver::class), $c->get(HttpDriver::class),