public function __construct($name = '')
{
$this->name = $name;
$appName = '\\' . get_class($this);
$fullname = Daemon::$appResolver->getAppFullName($appName, $this->name);
//Daemon::$process->log($fullname . ' instantiated.');
if ($this->requestClass === null) {
$this->requestClass = get_class($this) . 'Request';
if (!class_exists($this->requestClass)) {
$this->requestClass = null;
}
}
if (!isset(Daemon::$appInstances[$appName])) {
Daemon::$appInstances[$appName] = [];
}
Daemon::$appInstances[$appName][$this->name] = $this;
if (!isset(Daemon::$config->{$fullname})) {
Daemon::$config->{$fullname} = new Config\Section();
} else {
if (!isset(Daemon::$config->{$fullname}->enable) && !isset(Daemon::$config->{$fullname}->disable)) {
Daemon::$config->{$fullname}->enable = new Config\Entry\Generic();
Daemon::$config->{$fullname}->enable->setValue(true);
}
}
$this->config = Daemon::$config->{$fullname};
if ($this->isEnabled()) {
Daemon::$process->log($appName . ($name ? ":{$name}" : '') . ' up.');
}
$defaults = $this->getConfigDefaults();
if ($defaults) {
/** @noinspection PhpUndefinedMethodInspection */
$this->config->imposeDefault($defaults);
}
$this->init();
if (Daemon::$process instanceof Thread\Worker) {
if (!$this->ready) {
$this->ready = true;
$this->onReady();
}
}
}