Workaround for async init
This commit is contained in:
parent
7929e8053e
commit
3b4d45bd34
2
docs
2
docs
@ -1 +1 @@
|
||||
Subproject commit dc05dc5cebfcec90ac7851928c522a4d635dbab6
|
||||
Subproject commit d06f79a1848bd380d6ad9a71a3ead0c2c2ded4a1
|
@ -43,14 +43,28 @@ class API extends APIFactory
|
||||
$this->asyncAPIPromise = null;
|
||||
});
|
||||
$this->setInitPromise($this->__construct_async($params, $settings, $deferred));
|
||||
foreach (get_object_vars(new APIFactory('', $this, $this->async)) as $key => $var) {
|
||||
if (in_array($key, ['namespace', 'API', 'lua', 'async', 'asyncAPIPromise', 'methods', 'asyncInitPromise'])) {
|
||||
continue;
|
||||
}
|
||||
if (is_null($this->{$key})) {
|
||||
$this->{$key} = new APIFactory($key, $this->API, $this->async);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct_async($params, $settings, $deferred)
|
||||
{
|
||||
if (is_string($params)) {
|
||||
if (!\danog\MadelineProto\Logger::$default) {
|
||||
if (!isset($settings['logger']['logger_param'])) $settings['logger']['logger_param'] = Magic::$script_cwd.'/MadelineProto.log';
|
||||
if (!isset($settings['logger']['logger'])) $settings['logger']['logger'] = php_sapi_name() === 'cli' ? 3 : 2;
|
||||
if (!isset($settings['logger']['logger_param'])) {
|
||||
$settings['logger']['logger_param'] = Magic::$script_cwd.'/MadelineProto.log';
|
||||
}
|
||||
|
||||
if (!isset($settings['logger']['logger'])) {
|
||||
$settings['logger']['logger'] = php_sapi_name() === 'cli' ? 3 : 2;
|
||||
}
|
||||
|
||||
\danog\MadelineProto\Logger::constructor($settings['logger']['logger'], $settings['logger']['logger_param'], '', isset($settings['logger']['logger_level']) ? $settings['logger']['logger_level'] : Logger::VERBOSE, isset($settings['logger']['max_size']) ? $settings['logger']['max_size'] : 100 * 1024 * 1024);
|
||||
}
|
||||
$realpaths = Serialization::realpaths($params);
|
||||
|
@ -123,10 +123,10 @@ class APIFactory extends AsyncConstruct
|
||||
|
||||
protected $methods = [];
|
||||
|
||||
public function __construct($namespace, $API, &$async)
|
||||
public function __construct($namespace, &$API, &$async)
|
||||
{
|
||||
$this->namespace = $namespace.'.';
|
||||
$this->API = $API;
|
||||
$this->API = &$API;
|
||||
$this->async = &$async;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user