diff options
Diffstat (limited to 'app/ServiceProvider/ApiProvider.php')
-rw-r--r-- | app/ServiceProvider/ApiProvider.php | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/app/ServiceProvider/ApiProvider.php b/app/ServiceProvider/ApiProvider.php new file mode 100644 index 00000000..19d945f6 --- /dev/null +++ b/app/ServiceProvider/ApiProvider.php @@ -0,0 +1,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; + } +} |