Пример #1
0
 function configure(InjectorInterface $injector, ModuleServices $module, LoginSettings $settings, RouterInterface $router)
 {
     $injector->share(LoginSettings::class);
     $this->settings = $settings;
     $this->router = $router;
     $module->provideTranslations()->provideViews()->registerRouter($this, 'login', 'platform');
 }
Пример #2
0
 function boot($rootDir, $urlDepth = 0, callable $onStartUp = null)
 {
     $rootDir = normalizePath($rootDir);
     // Initialize some settings from environment variables
     $dotenv = new Dotenv("{$rootDir}/.env");
     try {
         $dotenv->load();
     } catch (ConfigException $e) {
         echo $e->getMessage();
         return 1;
     }
     // Load the kernel's configuration.
     /** @var KernelSettings $kernelSettings */
     $kernelSettings = $this->kernelSettings = $this->injector->share(KernelSettings::class, 'app')->make(KernelSettings::class);
     $kernelSettings->isWebBased = true;
     $kernelSettings->setApplicationRoot($rootDir, $urlDepth);
     // Setup debugging (must be done before instantiating the kernel, but after instantiating its settings).
     $this->setupDebugging($rootDir);
     // Boot up the framework's kernel.
     $this->injector->execute([KernelModule::class, 'register']);
     // Boot up the framework's subsytems and the application's modules.
     /** @var KernelInterface $kernel */
     $kernel = $this->injector->make(KernelInterface::class);
     if ($onStartUp) {
         $onStartUp($kernel);
     }
     // Boot up all modules.
     try {
         $kernel->boot();
     } catch (ConfigException $e) {
         $NL = "<br>\n";
         echo $e->getMessage() . $NL . $NL;
         if ($e->getCode() == -1) {
             echo sprintf('Possile error causes:%2$s%2$s- the class name may be misspelled,%2$s- the class may no longer exist,%2$s- module %1$s may be missing or it may be corrupted.%2$s%2$s', str_match($e->getMessage(), '/from module (\\S+)/')[1], $NL);
         }
         $path = "{$kernelSettings->storagePath}/" . ModulesRegistry::REGISTRY_FILE;
         if (file_exists($path)) {
             echo "Tip: one possible solution is to remove the '{$path}' file and run 'workman' to rebuild the module registry.";
         }
     }
     // Finalize.
     if ($kernel->devEnv()) {
         $this->setDebugPathsMap($this->injector->make(ModulesRegistry::class));
     }
     return $kernel->getExitCode();
 }