/** * @param CoreInterface $core * @throws Exception */ protected function boot(CoreInterface $core) { $config = $core->make('Surume\\Config\\ConfigInterface'); $factory = $core->make('Surume\\Channel\\ChannelModelFactoryInterface'); $models = (array) $config->get('channel.models'); foreach ($models as $modelClass) { if (!class_exists($modelClass)) { throw new ResourceUndefinedException("ChannelModel [{$modelClass}] does not exist."); } $factory->define($modelClass, function ($config) use($modelClass) { return new $modelClass($config); }); } $plugins = (array) $config->get('channel.plugins'); foreach ($plugins as $pluginClass) { if (!class_exists($pluginClass)) { throw new ResourceUndefinedException("FactoryPlugin [{$pluginClass}] does not exist."); } $plugin = new $pluginClass(); if (!$plugin instanceof FactoryPluginInterface) { throw new InvalidArgumentException("FactoryPlugin [{$pluginClass}] does not implement FactoryPluginInterface."); } $plugin->registerPlugin($factory); } }
/** * @param CoreInterface $core * @throws Exception */ protected function boot(CoreInterface $core) { $config = $core->make('Surume\\Config\\ConfigInterface'); $factory = $core->make('Surume\\Supervisor\\SolverFactoryInterface'); $handlers = (array) $config->get('error.handlers'); foreach ($handlers as $handlerClass) { if (!class_exists($handlerClass)) { throw new ResourceUndefinedException("Solver [{$handlerClass}] does not exist."); } $factory->define($handlerClass, function ($runtime, $context = []) use($handlerClass) { return new $handlerClass($runtime, $context); }); } $plugins = (array) $config->get('error.plugins'); foreach ($plugins as $pluginClass) { if (!class_exists($pluginClass)) { throw new ResourceUndefinedException("SupervisorPlugin [{$pluginClass}] does not exist."); } $plugin = new $pluginClass(); if (!$plugin instanceof FactoryPluginInterface) { throw new InvalidArgumentException("SupervisorPlugin [{$pluginClass}] does not implement SupervisorPluginInterface."); } $plugin->registerPlugin($factory); } }
/** * @param CoreInterface $core */ protected function boot(CoreInterface $core) { $runtime = $core->make('Surume\\Runtime\\RuntimeInterface'); $channel = $core->make('Surume\\Runtime\\Channel\\ChannelInterface'); $runtime->on('create', [$channel, 'start']); $runtime->on('destroy', [$channel, 'stop']); }
/** * @param CoreInterface $core * @throws Exception */ protected function boot(CoreInterface $core) { $config = $core->make('Surume\\Config\\ConfigInterface'); $baseSupervisor = $core->make('Surume\\Runtime\\Supervisor\\SupervisorBaseInterface'); $remoteSupervisor = $core->make('Surume\\Runtime\\Supervisor\\SupervisorRemoteInterface'); $this->bootBaseSupervisor($baseSupervisor, $config); $this->bootRemoteSupervisor($remoteSupervisor, $config); }
/** * @param CoreInterface $core */ protected function boot(CoreInterface $core) { $config = $core->make('Surume\\Config\\ConfigInterface'); $runtime = $core->make('Surume\\Runtime\\RuntimeInterface'); $factory = $core->make('Surume\\Command\\CommandFactoryInterface'); $manager = $core->make('Surume\\Command\\CommandManagerInterface'); $manager->import($this->defaultCommands($config, $factory, $runtime)); $manager->import($this->appCommands($config, $factory, $runtime)); }
/** * @param CoreInterface $core */ protected function boot(CoreInterface $core) { $runtime = $core->make('Surume\\Runtime\\RuntimeInterface'); $channel = $core->make('Surume\\Runtime\\Channel\\ChannelInterface'); $console = $core->make('Surume\\Runtime\\Channel\\ConsoleInterface'); $this->applyConsoleRouting($channel, $console); $runtime->on('create', [$console, 'start']); $runtime->on('destroy', [$console, 'stop']); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $loop = $core->make('Surume\\Loop\\LoopExtendedInterface'); $runtime = $core->make('Surume\\Runtime\\RuntimeInterface'); $error = $core->make('Surume\\Runtime\\Supervisor\\SupervisorBaseInterface'); $manager = $core->make('Surume\\Runtime\\RuntimeManagerInterface'); $model = $runtime->model(); $model->setLoop($loop); $model->setSupervisor($error); $model->setRuntimeManager($manager); }
/** * @param CoreInterface $core */ protected function boot(CoreInterface $core) { $runtime = $core->make('Surume\\Runtime\\RuntimeInterface'); $channel = $core->make('Surume\\Runtime\\Channel\\ChannelInterface'); $console = $core->make('Surume\\Runtime\\Channel\\ConsoleInterface'); if ($runtime->parent() === null) { $this->applyRootRouting($runtime, $channel, $console); } else { $this->applySimpleRouting($runtime, $channel); } $runtime->on('create', [$channel, 'start']); $runtime->on('destroy', [$channel, 'stop']); }
/** * @throws ExecutionException */ private function registerAliases() { foreach ($this->serviceAliases as $alias => $concrete) { try { $this->core->alias($alias, $concrete); } catch (Error $ex) { throw new ExecutionException("Alias [{$alias}] could not have be registered.", $ex); } catch (Exception $ex) { throw new ExecutionException("Alias [{$alias}] could not have be registered.", $ex); } } }
/** * @param CoreInterface $core */ protected function boot(CoreInterface $core) { $config = $core->make('Surume\\Config\\ConfigInterface'); $factory = $core->make('Surume\\Console\\Client\\Command\\CommandFactoryInterface'); $handler = $core->make('Surume\\Console\\Client\\Command\\CommandHandlerInterface'); $console = $core->make('Surume\\Console\\Client\\ConsoleClientInterface'); $cmds = (array) $factory->getDefinitions(); $commands = []; foreach ($cmds as $command => $definition) { $commands[] = $factory->create($command, [$handler]); } $this->symfony->addCommands($commands); $version = $core->version(); $console->onCommand(function () use($version) { echo "SurumePHP-v{$version}\n"; $this->symfony->run(); }); }
/** * @param CoreInterface $core */ protected function unregister(CoreInterface $core) { $core->remove('Surume\\Event\\EventEmitterInterface'); }
/** * @param CoreInterface $core */ protected function unregister(CoreInterface $core) { $core->remove('Surume\\Console\\Client\\Command\\CommandFactoryInterface'); }
/** * @param CoreInterface $core */ protected function unregister(CoreInterface $core) { $core->remove('Surume\\Console\\Client\\Channel\\ConsoleInterface'); }
/** * @param CoreInterface $core */ protected function boot(CoreInterface $core) { $runtime = $core->make('Surume\\Runtime\\RuntimeInterface'); $manager = $core->make('Surume\\Command\\CommandManagerInterface'); $manager->import($this->commands($runtime)); }
/** * @param CoreInterface $core */ protected function unregister(CoreInterface $core) { $core->remove('Surume\\Log\\LoggerInterface'); $core->remove('Surume\\Log\\LoggerFactory'); }
/** * @param CoreInterface $core */ protected function unregister(CoreInterface $core) { $core->remove('Surume\\Core\\CoreInputContextInterface'); $core->remove('Surume\\Runtime\\RuntimeInterface'); }
/** * @param CoreInterface $core * @return RuntimeInterface */ public function internalBoot(CoreInterface $core) { $core->registerProvider(new ConsoleProvider($this)); return $this->boot($core); }
/** * @param CoreInterface $core */ protected function unregister(CoreInterface $core) { $core->remove('Surume\\Loop\\LoopInterface'); $core->remove('Surume\\Loop\\LoopExtendedInterface'); }
/** * @param CoreInterface $core * @return RuntimeInterface */ public function internalBoot(CoreInterface $core) { $core->registerProvider(new RuntimeProvider($this)); $core->registerProvider(new RuntimeAutowireProvider()); return $this->boot($core); }
/** * @param CoreInterface $core * @param RuntimeManagerFactoryInterface $managerFactory * @param mixed[] $default * @param mixed[] $config * @return RuntimeManagerInterface */ private function createManager(CoreInterface $core, RuntimeManagerFactoryInterface $managerFactory, $default, $config) { $managerClass = $config['class']; $managerConfig = array_merge($default, $config['config']); foreach ($managerConfig as $key => $value) { if (is_string($value) && class_exists($value)) { $managerConfig[$key] = $core->make($value); } } return $managerFactory->create($managerClass, [$managerConfig]); }
/** * @param CoreInterface $core */ protected function boot(CoreInterface $core) { $console = $this->console; $loop = $core->make('Surume\\Loop\\LoopExtendedInterface'); $console->setLoop($loop); }
/** * @param CoreInterface $core * @param CoreInputContextInterface $context * @return string[] */ private function getDefaultVariables(CoreInterface $core, CoreInputContextInterface $context) { return ['runtime' => $context->type(), 'parent' => $context->parent(), 'alias' => $context->alias(), 'name' => $context->name(), 'basepath' => $core->basePath(), 'datapath' => $core->dataPath(), 'host.main' => '127.0.0.1']; }
/** * @param CoreInterface $core */ protected function unregister(CoreInterface $core) { $core->remove('Surume\\Core\\CoreInterface'); }
/** * @param CoreInterface $core */ protected function unregister(CoreInterface $core) { $core->remove('Surume\\Filesystem\\FilesystemInterface'); $core->remove('Surume\\Filesystem\\FilesystemManagerInterface'); }