adrema/app/Dav/ServiceProvider.php

69 lines
1.8 KiB
PHP
Raw Normal View History

2022-10-06 20:58:58 +02:00
<?php
namespace App\Dav;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use LaravelSabre\Http\Auth\AuthBackend;
use LaravelSabre\LaravelSabre;
use Sabre\CardDAV\AddressBookRoot;
2024-05-15 01:36:36 +02:00
use Sabre\CalDAV\CalendarRoot;
2022-10-06 20:58:58 +02:00
use Sabre\CardDAV\Plugin as CardDAVPlugin;
2024-05-15 01:36:36 +02:00
use Sabre\CalDAV\Plugin as CalDAVPlugin;
2022-10-06 20:58:58 +02:00
use Sabre\DAV\Auth\Plugin as AuthPlugin;
use Sabre\DAV\Browser\Plugin as BrowserPlugin;
use Sabre\DAVACL\AbstractPrincipalCollection;
2022-10-06 23:47:35 +02:00
use Sabre\DAVACL\Plugin as AclPlugin;
2022-10-06 20:58:58 +02:00
use Sabre\DAVACL\PrincipalCollection;
class ServiceProvider extends BaseServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
LaravelSabre::nodes(function () {
return $this->nodes();
});
LaravelSabre::plugins(fn () => $this->plugins());
LaravelSabre::auth(function () {
auth()->onceBasic();
return true;
});
}
/**
* List of nodes for DAV Collection.
*
* @return array<int, AbstractPrincipalCollection>
*/
private function nodes(): array
{
$principalBackend = new Principal();
$addressBookBackend = new AddressBookBackend();
2024-05-15 01:36:36 +02:00
$calendarBackend = new CalendarBackend();
2022-10-06 20:58:58 +02:00
return [
new PrincipalCollection($principalBackend),
new AddressBookRoot($principalBackend, $addressBookBackend),
2024-05-15 01:36:36 +02:00
new CalendarRoot($principalBackend, $calendarBackend),
2022-10-06 20:58:58 +02:00
];
}
private function plugins(): array
{
$authBackend = new AuthBackend();
return [
new BrowserPlugin(),
new AuthPlugin($authBackend),
new CardDAVPlugin(),
2024-05-15 01:36:36 +02:00
new CalDAVPlugin(),
2022-10-06 23:47:35 +02:00
new AclPlugin(),
2022-10-06 20:58:58 +02:00
];
}
}