/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $context = $core->make('Surume\\Core\\CoreInputContextInterface'); $global = $core->dataPath() . '/config-global/' . $this->getDir($core->unit()); $local = $core->dataPath() . '/config/' . $context->name(); $config = new Config(); $this->addConfigByPath($config, $global); $this->addConfigByPath($config, $local); $this->addConfig($config, new Config($core->config())); $vars = array_merge($config->exists('vars') ? $config->get('vars') : [], $this->getDefaultVariables($core, $context)); $records = ArraySupport::flatten($config->all()); foreach ($records as $key => $value) { $new = StringSupport::parametrize($value, $vars); if (is_string($value) && $new != $value) { $config->set($key, $new); } } $core->instance('Surume\\Config\\ConfigInterface', $config); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $system = new SystemUnix(); $config = $core->make('Surume\\Config\\ConfigInterface'); $env = $core->make('Surume\\Core\\EnvironmentInterface'); $fs = $core->make('Surume\\Filesystem\\FilesystemInterface'); $runtime = $core->make('Surume\\Runtime\\RuntimeInterface'); $channel = $core->make('Surume\\Runtime\\Channel\\ChannelInterface'); $this->registerRuntimeSupervision($runtime, $channel, $config); $defaultConfig = ['runtime' => $runtime, 'channel' => $channel, 'env' => $env, 'system' => $system, 'filesystem' => $fs, 'receiver' => $runtime->parent()]; $factoryProcess = new ProcessManagerFactory(); $factoryThread = new ThreadManagerFactory(); if ($core->unit() === Runtime::UNIT_THREAD) { $factoryProcess->remove('Surume\\Runtime\\Container\\Manager\\ProcessManagerBase'); } $managerProcess = $this->createManager($core, $factoryProcess, $defaultConfig, $config->get('runtime.manager.process')); $managerThread = $this->createManager($core, $factoryThread, $defaultConfig, $config->get('runtime.manager.thread')); $managerRuntime = new RuntimeManager($managerProcess, $managerThread); $core->instance('Surume\\Runtime\\Container\\ProcessManagerInterface', $managerProcess); $core->instance('Surume\\Runtime\\Container\\ThreadManagerInterface', $managerThread); $core->instance('Surume\\Runtime\\RuntimeManagerInterface', $managerRuntime); }