114 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			114 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| use Tell\I18n;
 | |
| 
 | |
| use TheBugs\JavascriptMiddleware;
 | |
| 
 | |
| use Lean\Lean;
 | |
| 
 | |
| use Storage\Cookie,
 | |
|     Storage\Session,
 | |
|     Storage\SessionMiddleware;
 | |
| 
 | |
| use function DI\autowire, DI\create, DI\get, DI\add;
 | |
| 
 | |
| $dir = dirname(__DIR__, 2);
 | |
| 
 | |
| return [
 | |
|     'lean.default' => [
 | |
|         'picea' => [
 | |
|             'context' => "Lean\\View",
 | |
| 
 | |
|             'view' => [
 | |
|                 [
 | |
|                     'path' => getenv("VIEW_PATH"),
 | |
|                     'order' => 10,
 | |
|                 ],
 | |
|                 [
 | |
|                     'path' => implode(DIRECTORY_SEPARATOR, [ $dir, "view", '' ]),
 | |
|                     'order' => 99,
 | |
|                 ],
 | |
|             ],
 | |
| 
 | |
|             'asset' => [
 | |
|                 [
 | |
|                     'path' => implode(DIRECTORY_SEPARATOR, [ getenv("PROJECT_PATH"), "asset", '' ]),
 | |
|                     'order' => 10
 | |
|                 ]
 | |
|             ],
 | |
| 
 | |
|             'extensions' => [],
 | |
|         ],
 | |
| 
 | |
|         'ulmus' => [],
 | |
| 
 | |
|         'tell' => [
 | |
|             'json' => [
 | |
|                 [
 | |
|                     'path' => getenv("META_PATH") . "/i18n",
 | |
|                     'order' => 10,
 | |
|                 ],
 | |
| 
 | |
|                 [
 | |
|                     'path' => getenv("PROJECT_PATH") . "/vendor/mcnd/lean/meta/i18n",
 | |
|                     'order' => 99,
 | |
|                 ],
 | |
|             ],
 | |
| 
 | |
|             'php' => [
 | |
|                 [
 | |
|                     'path' => getenv("CACHE_PATH")."/i18n",
 | |
|                     'order' => 0,
 | |
|                 ]
 | |
|             ]
 | |
|         ],
 | |
| 
 | |
|         'routes' => [],
 | |
| 
 | |
|         'cronard' => [],
 | |
| 
 | |
|         'taxus' => [
 | |
|             'is_dev' => [ ' dev' => "Is a developper of this application or has the same rights" ],
 | |
|             'is_admin' => [ 'admin' => "Can manage almost everything in this application."],
 | |
|             'is_moderator' => [ 'moderator' => "Can moderate this application."],
 | |
|             'is_user' => [ 'user' => "Is an authenticated user."],
 | |
|             'is_anonymous' => [ 'anonymous' => "Is an anonymous user."],
 | |
|         ],
 | |
|     ],
 | |
| 
 | |
|     'lean.autoload' => add([
 | |
|         Lean::class,
 | |
|     ]),
 | |
| 
 | |
|     Lean::class => autowire(Lean::class),
 | |
| 
 | |
|     JavascriptMiddleware::class => create(JavascriptMiddleware::class),
 | |
| 
 | |
|     Cookie::class => create(Cookie::class)->constructor([ 'secure' => true, 'path' => getenv('URL_BASE') ?: '/',  ], getenv("LEAN_RANDOM")),
 | |
| 
 | |
|     Session::class => create(Session::class)->constructor(get(Cookie::class), [ 'path' => getenv('URL_BASE') ?: '/',  ]),
 | |
| 
 | |
|     SessionMiddleware::class => create(SessionMiddleware::class)->constructor(get(Cookie::class), [ 'name' => "lean_sess_" . substr(md5(getenv("LEAN_RANDOM")), 0, 12), 'path' => getenv('URL_BASE') ?: '/' ]),
 | |
| 
 | |
|     'git.commit' => function($c) {
 | |
|         if ( getenv("DEBUG") ) {
 | |
|             return uniqid("debug_");
 | |
|         }
 | |
| 
 | |
|         $gitdir = getenv("PROJECT_PATH") . DIRECTORY_SEPARATOR . ".git" . DIRECTORY_SEPARATOR;
 | |
| 
 | |
|         if ( file_exists($gitdir . "HEAD") ) {
 | |
|             if (false !== ($currentBranch = file_get_contents($gitdir  . "HEAD"))) {
 | |
|                 $file = explode(": ", $currentBranch)[1];
 | |
|                 $path = $gitdir . str_replace("/", DIRECTORY_SEPARATOR, trim($file, " \t\n\r"));
 | |
| 
 | |
|                 return file_exists($path) ? trim(file_get_contents($path), " \t\n\r") : null;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         return "gitless-project";
 | |
|     },
 | |
| 
 | |
|     Kash\CacheInvalidator::class => create(Kash\CacheInvalidator::class)->constructor(getenv('CACHE_PATH')."/version.cache", (bool) getenv('DEBUG')),
 | |
| ];
 |