bootstrap.php 2.34 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?php
/**
 * 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
 */

return function (Slim\App $app) {

    $container = $app->getContainer();

    $container['autoloader']->addPsr4('GrEduLabs\\Schools\\', __DIR__ . '/src/');

    $container[GrEduLabs\Schools\Action\Index::class] = function ($c) {
18 19 20 21
        return new GrEduLabs\Schools\Action\Index(
            $c->get('view'),
            $c->get('schoolservice')
        );
22 23 24
    };

    $container[GrEduLabs\Schools\Action\Staff::class] = function ($c) {
25 26 27 28 29 30 31 32 33 34
        return new GrEduLabs\Schools\Action\Staff(
            $c->get('view'),
            $c->get('staffservice')
            );
    };

    $container[GrEduLabs\Schools\Action\StaffCreate::class] = function ($c) {
        return new GrEduLabs\Schools\Action\StaffCreate(
            $c->get('staffservice')
            );
35 36 37
    };

    $container[GrEduLabs\Schools\Action\Labs::class] = function ($c) {
38 39 40
        return new GrEduLabs\Schools\Action\Labs(
            $c->get('view')
            );
41 42 43 44 45 46
    };

    $container[GrEduLabs\Schools\Action\Assets::class] = function ($c) {
        return new GrEduLabs\Schools\Action\Assets($c->get('view'));
    };

47 48 49 50 51 52 53 54 55 56 57
    $container['schoolservice'] = function($c){
        return new GrEduLabs\Schools\Service\SchoolService();
    };

    $container['staffservice'] = function($c){
        return new GrEduLabs\Schools\Service\StaffService(
            $c->get('schoolservice')
        );
    };


58 59 60 61 62 63 64 65 66 67 68
    $events = $container['events'];

    $events('on', 'bootstrap', function () use ($container) {
        $container['view']->getEnvironment()->getLoader()->prependPath(__DIR__ . '/templates');
    });

    $app->group('/school', function () {
        $this->get('', GrEduLabs\Schools\Action\Index::class)->setName('school');
        $this->get('/staff', GrEduLabs\Schools\Action\Staff::class)->setName('school.staff');
        $this->get('/labs', GrEduLabs\Schools\Action\Labs::class)->setName('school.labs');
        $this->get('/assets', GrEduLabs\Schools\Action\Assets::class)->setName('school.assets');
69
        $this->post('/staff', GrEduLabs\Schools\Action\StaffCreate::class)->setName('school.staffcreate');
70 71
    });
};