summaryrefslogtreecommitdiff
path: root/app/ServiceProvider/ApiProvider.php
blob: 19d945f6e14c3d5ffc274ec0276e54f95d5d4ee6 (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
<?php

namespace Kanboard\ServiceProvider;

use JsonRPC\Server;
use Kanboard\Api\ActionApi;
use Kanboard\Api\AppApi;
use Kanboard\Api\BoardApi;
use Kanboard\Api\CategoryApi;
use Kanboard\Api\ColumnApi;
use Kanboard\Api\CommentApi;
use Kanboard\Api\FileApi;
use Kanboard\Api\GroupApi;
use Kanboard\Api\GroupMemberApi;
use Kanboard\Api\LinkApi;
use Kanboard\Api\MeApi;
use Kanboard\Api\Middleware\AuthenticationApiMiddleware;
use Kanboard\Api\ProjectApi;
use Kanboard\Api\ProjectPermissionApi;
use Kanboard\Api\SubtaskApi;
use Kanboard\Api\SwimlaneApi;
use Kanboard\Api\TaskApi;
use Kanboard\Api\TaskLinkApi;
use Kanboard\Api\UserApi;
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 AuthenticationApiMiddleware($container))
        ;

        $server->getProcedureHandler()
            ->withObject(new MeApi($container))
            ->withObject(new ActionApi($container))
            ->withObject(new AppApi($container))
            ->withObject(new BoardApi($container))
            ->withObject(new ColumnApi($container))
            ->withObject(new CategoryApi($container))
            ->withObject(new CommentApi($container))
            ->withObject(new FileApi($container))
            ->withObject(new LinkApi($container))
            ->withObject(new ProjectApi($container))
            ->withObject(new ProjectPermissionApi($container))
            ->withObject(new SubtaskApi($container))
            ->withObject(new SwimlaneApi($container))
            ->withObject(new TaskApi($container))
            ->withObject(new TaskLinkApi($container))
            ->withObject(new UserApi($container))
            ->withObject(new GroupApi($container))
            ->withObject(new GroupMemberApi($container))
        ;
        
        $container['api'] = $server;
        return $container;
    }
}