mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-23 23:20:57 +01:00
Add context dependency container
This commit is contained in:
parent
3dc239e204
commit
c20b0ba6f0
28
inc/context.php
Normal file
28
inc/context.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
namespace Vichan;
|
||||||
|
|
||||||
|
defined('TINYBOARD') or exit;
|
||||||
|
|
||||||
|
use Vichan\Driver\{HttpDriver, HttpDrivers};
|
||||||
|
|
||||||
|
|
||||||
|
interface Context {
|
||||||
|
public function getHttpDriver(): HttpDriver;
|
||||||
|
}
|
||||||
|
|
||||||
|
class AppContext implements Context {
|
||||||
|
private array $config;
|
||||||
|
private ?HttpDriver $http;
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct(array $config) {
|
||||||
|
$this->config = $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHttpDriver(): HttpDriver {
|
||||||
|
if (is_null($this->http)) {
|
||||||
|
$this->http = HttpDrivers::getHttpDriver($this->config['upload_by_url_timeout'], $this->config['max_filesize']);
|
||||||
|
}
|
||||||
|
return $this->http;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user