Exemplo n.º 1
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;
 }
Exemplo n.º 2
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;
 }