]> git.agnieray.net Git - galette.git/blob - galette/lib/Galette/Core/SlimApp.php
ad9716fd8f7caf1f1ad2a62a677b1fec7d5a7e0d
[galette.git] / galette / lib / Galette / Core / SlimApp.php
1 <?php
2
3 /**
4 * Copyright © 2003-2024 The Galette Team
5 *
6 * This file is part of Galette (https://galette.eu).
7 *
8 * Galette is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Galette is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 namespace Galette\Core;
23
24 use DI\Bridge\Slim\Bridge;
25 use DI\ContainerBuilder;
26 use Slim\App;
27
28 /**
29 * Slim application
30 *
31 * @author Johan Cwiklinski <johan@x-tnd.be>
32 */
33 class SlimApp
34 {
35 /** @var App */
36 private App $app;
37
38 /**
39 * Create a new Slim application
40 */
41 public function __construct()
42 {
43 $builder = new ContainerBuilder();
44 $builder->useAttributes(true);
45 $builder->addDefinitions([
46 'galette' => [
47 'mode' => GALETTE_MODE,
48 'logger' => [
49 'name' => 'galette',
50 'level' => \Monolog\Logger::DEBUG,
51 'path' => GALETTE_LOGS_PATH . '/galette_slim.log',
52 ]
53 ],
54 'mode' => GALETTE_MODE, //TODO: rely on galette.mode
55 'galette.mode' => GALETTE_MODE,
56 'session' => \DI\autowire('\RKA\Session')
57 ]);
58 $container = $builder->build();
59
60 $this->app = Bridge::create($container);
61 }
62
63 /**
64 * Get Slim application
65 *
66 * @return App
67 */
68 public function getApp(): App
69 {
70 return $this->app;
71 }
72 }