bootstrap.php 2.5 KB
Newer Older
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
1
<?php
2
3

use GrEduLabs\Schools\InputFilter\School as SchoolInputFilter;
4
5
use GrEduLabs\Schools\Service\AssetServiceInterface;
use GrEduLabs\Schools\Service\LabServiceInterface;
6
7
use GrEduLabs\Schools\Service\SchoolServiceInterface;
use SchMM\FetchUnit;
8
use SchSync\Middleware\CreateLabs;
9
10
11
use SchSync\Middleware\CreateSchool;
use SchSync\Middleware\CreateUser;
use Slim\App;
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
12
13
14
15
16
17
18
19
20
/**
 * gredu_labs.
 * 
 * @link https://github.com/eellak/gredu_labs for the canonical source repository
 *
 * @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
 * @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
 */

21
return function (App $app) {
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
22
23

    $container = $app->getContainer();
24
    $events    = $container['events'];
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
25

26
27
28
    $events('on', 'app.autoload', function ($stop, $autoloader) {
        $autoloader->addPsr4('SchSync\\', __DIR__ . '/src');
    });
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
29

30
    $events('on', 'app.services', function ($stop, $container) {
31
32
33
34
35
36
37
        $container[CreateUser::class] = function ($c) {
            return new CreateUser(
                $c->get('authentication_service'),
                $c->get('router')->pathFor('user.login'),
                $c->get('router')->pathFor('user.logout.sso'),
                $c->get('flash'),
                $c->get('logger')
38
39
            );
        };
40
41
42
43
44
45
46
47
48
49
50
        $container[CreateSchool::class] = function ($c) {
            return new CreateSchool(
                $c->get('ldap'),
                $c->get(FetchUnit::class),
                $c->get('authentication_service'),
                $c->get(SchoolServiceInterface::class),
                $c->get(SchoolInputFilter::class),
                $c->get('router')->pathFor('user.login'),
                $c->get('router')->pathFor('user.logout.sso'),
                $c->get('flash'),
                $c->get('logger')
51
52
            );
        };
53
54
55
56
57
58
59
60
61
62
        $container[CreateLabs::class] = function ($c) {
            return new CreateLabs(
                $c->get(LabServiceInterface::class),
                $c->get(AssetServiceInterface::class),
                $c->get('SchInventory\\Service'),
                $c->get(SchoolServiceInterface::class),
                $c->get('authentication_service'),
                $c->get('logger')
            );
        };
63
    });
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
64

65
    $events('on', 'app.bootstrap', function ($stop, $app, $container) {
66
67
68
69
        $container['router']->getNamedRoute('user.login.sso')
            ->add(CreateUser::class)
            ->add(CreateSchool::class)
            ->add(CreateLabs::class);
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
70
    }, -10);
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
71
};