Author: Gawain Lynch (gawain.lynch@gmail.com)
Exemple #1
0
 /**
  * @param array $values
  */
 public function __construct(array $values = [])
 {
     /** @internal Parameter to track a deprecated PHP version */
     $values['deprecated.php'] = version_compare(PHP_VERSION, '5.5.9', '<');
     // Register PHP shutdown functions to catch fatal errors & exceptions
     ShutdownHandler::register();
     parent::__construct($values);
     $this->register(new PathServiceProvider());
     // Initialize the config. Note that we do this here, on 'construct'.
     // All other initialisation is triggered from bootstrap.php
     // Warning!
     // One of a valid ResourceManager ['resources'] or ClassLoader ['classloader']
     // must be defined for working properly
     if (!isset($this['resources'])) {
         $this['resources'] = new Configuration\ResourceManager($this);
     } else {
         $this['classloader'] = $this['resources']->getClassLoader();
     }
     $this['resources']->setApp($this);
     $this->initConfig();
     $this->initLogger();
     $this['resources']->initialize();
     if (($debugOverride = $this['config']->get('general/debug')) !== null) {
         $this['debug'] = $debugOverride;
     }
     // Re-register the shutdown functions now that we know our debug setting
     ShutdownHandler::register($this['debug']);
     if (!isset($this['environment'])) {
         $this['environment'] = $this['debug'] ? 'development' : 'production';
     }
     if (($locales = $this['config']->get('general/locale')) !== null) {
         $locales = (array) $locales;
         $this['locale'] = reset($locales);
     }
     // Initialize the 'editlink' and 'edittitle'.
     $this['editlink'] = '';
     $this['edittitle'] = '';
     // Initialize the JavaScript data gateway.
     $this['jsdata'] = [];
 }
Exemple #2
0
 $error = true;
 foreach ($autodetectionMappings as $autoloadPath => list($resourcesClass, $rootPath)) {
     if (!file_exists($autoloadPath)) {
         continue;
     }
     require_once $autoloadPath;
     $error = false;
     break;
 }
 // None of the mappings matched, error
 if ($error) {
     include $boltRootPath . '/src/Exception/BootException.php';
     BootException::earlyExceptionComposer();
 }
 // Register handlers early
 ShutdownHandler::register();
 /*
  * Load initialization config needed to bootstrap application.
  *
  * In order for paths to be customized and still have the standard
  * index.php (web) and nut (CLI) work, there needs to be a standard
  * place these are defined. This is ".bolt.yml" or ".bolt.php" in the
  * project root (determined above).
  *
  * Yes, YAML and PHP are supported here (not both). YAML works for
  * simple values and PHP supports any programmatic logic if required.
  */
 $config = ['application' => null, 'resources' => null, 'paths' => []];
 if (file_exists($rootPath . '/.bolt.yml')) {
     $yaml = Yaml::parse(file_get_contents($rootPath . '/.bolt.yml')) ?: [];
     $config = array_replace_recursive($config, $yaml);