Пример #1
0
 /**
  * @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);
     }
 }
Пример #2
0
 /**
  * @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);
     }
 }
Пример #3
0
 /**
  * @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']);
 }
Пример #4
0
 /**
  * @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);
 }
Пример #5
0
 /**
  * @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));
 }
Пример #6
0
 /**
  * @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']);
 }
Пример #7
0
 /**
  * @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);
 }
Пример #8
0
 /**
  * @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']);
 }
Пример #9
0
 /**
  * @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);
         }
     }
 }
Пример #10
0
 /**
  * @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();
     });
 }
Пример #11
0
 /**
  * @param CoreInterface $core
  */
 protected function unregister(CoreInterface $core)
 {
     $core->remove('Surume\\Event\\EventEmitterInterface');
 }
Пример #12
0
 /**
  * @param CoreInterface $core
  */
 protected function unregister(CoreInterface $core)
 {
     $core->remove('Surume\\Console\\Client\\Command\\CommandFactoryInterface');
 }
Пример #13
0
 /**
  * @param CoreInterface $core
  */
 protected function unregister(CoreInterface $core)
 {
     $core->remove('Surume\\Console\\Client\\Channel\\ConsoleInterface');
 }
Пример #14
0
 /**
  * @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));
 }
Пример #15
0
 /**
  * @param CoreInterface $core
  */
 protected function unregister(CoreInterface $core)
 {
     $core->remove('Surume\\Log\\LoggerInterface');
     $core->remove('Surume\\Log\\LoggerFactory');
 }
Пример #16
0
 /**
  * @param CoreInterface $core
  */
 protected function unregister(CoreInterface $core)
 {
     $core->remove('Surume\\Core\\CoreInputContextInterface');
     $core->remove('Surume\\Runtime\\RuntimeInterface');
 }
Пример #17
0
 /**
  * @param CoreInterface $core
  * @return RuntimeInterface
  */
 public function internalBoot(CoreInterface $core)
 {
     $core->registerProvider(new ConsoleProvider($this));
     return $this->boot($core);
 }
Пример #18
0
 /**
  * @param CoreInterface $core
  */
 protected function unregister(CoreInterface $core)
 {
     $core->remove('Surume\\Loop\\LoopInterface');
     $core->remove('Surume\\Loop\\LoopExtendedInterface');
 }
Пример #19
0
 /**
  * @param CoreInterface $core
  * @return RuntimeInterface
  */
 public function internalBoot(CoreInterface $core)
 {
     $core->registerProvider(new RuntimeProvider($this));
     $core->registerProvider(new RuntimeAutowireProvider());
     return $this->boot($core);
 }
Пример #20
0
 /**
  * @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]);
 }
Пример #21
0
 /**
  * @param CoreInterface $core
  */
 protected function boot(CoreInterface $core)
 {
     $console = $this->console;
     $loop = $core->make('Surume\\Loop\\LoopExtendedInterface');
     $console->setLoop($loop);
 }
Пример #22
0
 /**
  * @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'];
 }
Пример #23
0
 /**
  * @param CoreInterface $core
  */
 protected function unregister(CoreInterface $core)
 {
     $core->remove('Surume\\Core\\CoreInterface');
 }
Пример #24
0
 /**
  * @param CoreInterface $core
  */
 protected function unregister(CoreInterface $core)
 {
     $core->remove('Surume\\Filesystem\\FilesystemInterface');
     $core->remove('Surume\\Filesystem\\FilesystemManagerInterface');
 }