initialize() public method

public initialize ( )
 protected function getApp()
 {
     $sessionMock = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Session\\Session')->setMethods(array('clear'))->setConstructorArgs(array(new MockFileSessionStorage()))->getMock();
     $config = new Config\ResourceManager(TEST_ROOT);
     $bolt = new Application(array('resources' => $config));
     $bolt['config']->set('general/database', array('driver' => 'sqlite', 'databasename' => 'test', 'username' => 'test', 'memory' => true));
     $bolt['session'] = $sessionMock;
     $bolt['resources']->setPath('files', __DIR__ . "/files");
     $bolt->initialize();
     return $bolt;
 }
Exemplo n.º 2
0
    // Resolve Bolt-root
    $boltRootPath = realpath(__DIR__ . '/..');
    // Look for the autoloader in known positions relative to the Bolt-root,
    // and autodetect an appropriate configuration class based on this
    // information. (autoload.php path maps to a configuration class)
    $autodetectionMappings = array($boltRootPath . '/vendor/autoload.php' => 'Standard', $boltRootPath . '/../../autoload.php' => 'Composer');
    foreach ($autodetectionMappings as $autoloadPath => $configType) {
        if (file_exists($autoloadPath)) {
            $loader = (require $autoloadPath);
            $configClass = '\\Bolt\\Configuration\\' . $configType;
            $config = new $configClass($loader);
            break;
        }
    }
    // None of the mappings matched, error
    if (!isset($config)) {
        throw new LowlevelException("Configuration autodetection failed because The file " . "<code>vendor/autoload.php</code> doesn't exist. Make sure " . "you've installed the required components with Composer.");
    }
    // Register a PHP shutdown function to catch fatal error
    register_shutdown_function(array('\\Bolt\\Exception\\LowlevelException', 'catchFatalErrors'));
    /**
     * @var $config Configuration\ResourceManager
     */
    $config->verify();
    $config->compat();
    // Create the 'Bolt application'
    $app = new Application(array('resources' => $config));
    // Initialize the 'Bolt application': Set up all routes, providers, database, templating, etc..
    $app->initialize();
    return $app;
});