summaryrefslogtreecommitdiff
path: root/app/ServiceProvider/ApiProvider.php
blob: 1bcb580a2065b292bb960b7ba99cba4d73d9b1e2 (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
82
83
84
85
86
87
88
89
<?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\ProjectMetadataProcedure;
use Kanboard\Api\Procedure\TagProcedure;
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\TaskMetadataProcedure;
use Kanboard\Api\Procedure\TaskProcedure;
use Kanboard\Api\Procedure\TaskLinkProcedure;
use Kanboard\Api\Procedure\TaskTagProcedure;
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 ProjectMetadataProcedure($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 TaskMetadataProcedure($container))
            ->withObject(new TaskTagProcedure($container))
            ->withObject(new UserProcedure($container))
            ->withObject(new GroupProcedure($container))
            ->withObject(new GroupMemberProcedure($container))
            ->withObject(new TagProcedure($container))
            ->withBeforeMethod('beforeProcedure')
        ;

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