summaryrefslogtreecommitdiff
path: root/app/ServiceProvider/ApiProvider.php
blob: 5cf6231cadcb736c11ab4b91250b70e6eb5287ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php

namespace Kanboard\ServiceProvider;

use JsonRPC\Server;
use Kanboard\Api\Procedure\ActionProcedure;
use Kanboard\Api\Procedure\AppProcedure;
use Kanboard\Api\Procedure\BoardProcedure;
use Kanboard\Api\Procedure\CategoryProcedure;
use Kanboard\Api\Procedure\ColumnProcedure;
use Kanboard\Api\Procedure\CommentProcedure;
use Kanboard\Api\Procedure\ProjectFileProcedure;
use Kanboard\Api\Procedure\TaskExternalLinkProcedure;
use Kanboard\Api\Procedure\TaskFileProcedure;
use Kanboard\Api\Procedure\GroupProcedure;
use Kanboard\Api\Procedure\GroupMemberProcedure;
use Kanboard\Api\Procedure\LinkProcedure;
use Kanboard\Api\Procedure\MeProcedure;
use Kanboard\Api\Middleware\AuthenticationMiddleware;
use Kanboard\Api\Procedure\ProjectProcedure;
use Kanboard\Api\Procedure\ProjectPermissionProcedure;
use Kanboard\Api\Procedure\SubtaskProcedure;
use Kanboard\Api\Procedure\SubtaskTimeTrackingProcedure;
use Kanboard\Api\Procedure\SwimlaneProcedure;
use Kanboard\Api\Procedure\TaskProcedure;
use Kanboard\Api\Procedure\TaskLinkProcedure;
use Kanboard\Api\Procedure\UserProcedure;
use Pimple\Container;
use Pimple\ServiceProviderInterface;

/**
 * Class ApiProvider
 *
 * @package Kanboard\ServiceProvider
 * @author  Frederic Guillot
 */
class ApiProvider implements ServiceProviderInterface
{
    /**
     * Registers services on the given container.
     *
     * @param Container $container
     * @return Container
     */
    public function register(Container $container)
    {
        $server = new Server();
        $server->setAuthenticationHeader(API_AUTHENTICATION_HEADER);
        $server->getMiddlewareHandler()
            ->withMiddleware(new AuthenticationMiddleware($container))
        ;

        $server->getProcedureHandler()
            ->withObject(new MeProcedure($container))
            ->withObject(new ActionProcedure($container))
            ->withObject(new AppProcedure($container))
            ->withObject(new BoardProcedure($container))
            ->withObject(new ColumnProcedure($container))
            ->withObject(new CategoryProcedure($container))
            ->withObject(new CommentProcedure($container))
            ->withObject(new TaskFileProcedure($container))
            ->withObject(new ProjectFileProcedure($container))
            ->withObject(new LinkProcedure($container))
            ->withObject(new ProjectProcedure($container))
            ->withObject(new ProjectPermissionProcedure($container))
            ->withObject(new SubtaskProcedure($container))
            ->withObject(new SubtaskTimeTrackingProcedure($container))
            ->withObject(new SwimlaneProcedure($container))
            ->withObject(new TaskProcedure($container))
            ->withObject(new TaskLinkProcedure($container))
            ->withObject(new TaskExternalLinkProcedure($container))
            ->withObject(new UserProcedure($container))
            ->withObject(new GroupProcedure($container))
            ->withObject(new GroupMemberProcedure($container))
            ->withBeforeMethod('beforeProcedure')
        ;

        $container['api'] = $server;
        return $container;
    }
}