Пример #1
0
 /**
  * @param ApplicationInterface|Application $application
  */
 private function registerModuleManager(ApplicationInterface $application)
 {
     $container = $application->getContainer();
     if (!$container->has(ModuleManagerInterface::class)) {
         $container->share(ModuleManagerInterface::class, $container->get('application.internal.moduleManager', [$application]));
     }
 }
Пример #2
0
 /**
  * Create configurator instance with configuration from internal configurator
  *
  * @param ApplicationInterface|Application $application
  * @param ComponentManager $runner
  *
  * @return bool
  *
  */
 public function init(ApplicationInterface $application, ComponentManager $runner)
 {
     $options = ['cache' => false];
     $data = $runner->getData();
     $configuration = isset($data['config']) ? $data['config'] : [];
     $options = $runner->getOptions($this);
     foreach ($configuration as $key => $file) {
         if (is_array($file)) {
             unset($configuration[$key]);
             continue;
         }
         if (!is_file($file)) {
             unset($configuration[$key]);
         }
     }
     $application->getContainer()->share(ConfiguratorInterface::class, $application->getContainer()->get('application.internal.config', [$configuration, $options]));
     return true;
 }
Пример #3
0
 /**
  * Initialize dot env files from configuration
  *
  * ```
  * $options['config'] = [
  *      __DIR__ . '/.env',
  *      __DIR__ . '/customfile.env',
  * ];
  * ```
  *
  * @param Application|ApplicationInterface $application
  * @param ComponentManager $runner
  * @return bool
  */
 public function init(ApplicationInterface $application, ComponentManager $runner)
 {
     $data = $runner->getData();
     if (!array_key_exists('config', $data)) {
         return false;
     }
     $configuration = $data['config'];
     foreach ($configuration as $key => $path) {
         if (!is_string($path)) {
             continue;
         }
         if (substr($path, -4) !== '.env') {
             continue;
         }
         $application->getContainer()->get(Dotenv::class, [dirname($path), basename($path)]);
         unset($data['config'][$key]);
     }
     $runner->setData($data);
     return true;
 }
Пример #4
0
 /**
  * Initialize application provider
  *
  * @param ApplicationInterface|Application $application
  * @param ComponentManager $runner
  *
  * @return bool
  *
  */
 public function init(ApplicationInterface $application, ComponentManager $runner)
 {
     $application->getContainer()->addServiceProvider(ApplicationProvider::class);
     return true;
 }