1
0
mirror of https://gitnet.fr/deblan/gist.git synced 2021-08-14 08:30:49 +02:00
GIST/app/bootstrap.php

37 lines
796 B
PHP
Raw Normal View History

2015-05-05 20:33:05 +02:00
<?php
require __DIR__.'/../vendor/autoload.php';
/**
* Wrap everything in a closure to preserve global scope and return the
* application.
*/
return call_user_func(function () {
$app = null;
/**
* This closure will be used to require other init files with a clean
* scope, with only access to `$app`.
*/
$closure = function () use (&$app) {
require func_get_arg(0);
};
$files = array();
foreach (new DirectoryIterator(__FILE__ . '.d') as $file) {
2015-05-06 00:18:16 +02:00
if (!$file->isDot() && $file->isFile() && $file->getBasename()[0] !== '.') {
2015-05-05 20:33:05 +02:00
$files[] = $file->getPathname();
}
}
// Sort init files, order is important
sort($files);
foreach ($files as $file) {
$closure($file);
}
return $app;
});