diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 9a0d2efef..33cc7f9ba 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -38,7 +38,8 @@ jobs: - name: Set up php${{ steps.versions.outputs.php-available }} uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e # v2.34.1 with: - php-version: ${{ steps.versions.outputs.php-available }} + # php-version: ${{ steps.versions.outputs.php-available }} + php-version: '8.2' extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite coverage: none ini-file: development diff --git a/appinfo/info.xml b/appinfo/info.xml index c720ab88d..e2406c8b3 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -76,10 +76,6 @@ OCA\GroupFolders\DAV\RootCollection - - OCA\GroupFolders\DAV\PropFindPlugin - OCA\GroupFolders\DAV\ACLPlugin - diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index e2a10e475..877af3891 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -10,6 +10,7 @@ use OCA\Circles\Events\CircleDestroyedEvent; use OCA\DAV\Connector\Sabre\Principal; +use OCA\DAV\Events\SabrePluginAddEvent; use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent; use OCA\Files_Trashbin\Expiration; @@ -26,9 +27,11 @@ use OCA\GroupFolders\Command\ExpireGroup\ExpireGroupVersions; use OCA\GroupFolders\Command\ExpireGroup\ExpireGroupVersionsTrash; use OCA\GroupFolders\Folder\FolderManager; +use OCA\GroupFolders\Listeners\ACLPluginListener; use OCA\GroupFolders\Listeners\CircleDestroyedEventListener; use OCA\GroupFolders\Listeners\LoadAdditionalScriptsListener; use OCA\GroupFolders\Listeners\NodeRenamedListener; +use OCA\GroupFolders\Listeners\PropFindPluginListener; use OCA\GroupFolders\Mount\FolderStorageManager; use OCA\GroupFolders\Mount\MountProvider; use OCA\GroupFolders\Trash\TrashBackend; @@ -78,6 +81,8 @@ public function register(IRegistrationContext $context): void { $context->registerEventListener(BeforeTemplateRenderedEvent::class, LoadAdditionalScriptsListener::class); $context->registerEventListener(CircleDestroyedEvent::class, CircleDestroyedEventListener::class); $context->registerEventListener(NodeRenamedEvent::class, NodeRenamedListener::class); + $context->registerEventListener(SabrePluginAddEvent::class, ACLPluginListener::class); + $context->registerEventListener(SabrePluginAddEvent::class, PropFindPluginListener::class); $context->registerService(MountProvider::class, function (ContainerInterface $c): MountProvider { /** @var IAppConfig $config */ diff --git a/lib/Listeners/ACLPluginListener.php b/lib/Listeners/ACLPluginListener.php new file mode 100644 index 000000000..c31c899c3 --- /dev/null +++ b/lib/Listeners/ACLPluginListener.php @@ -0,0 +1,50 @@ + + */ +class ACLPluginListener implements IEventListener { + public function __construct( + private RuleManager $ruleManager, + private IUserSession $userSession, + private FolderManager $folderManager, + private IEventDispatcher $eventDispatcher, + private ACLManagerFactory $aclManagerFactory, + private IL10N $l10n, + ) { + } + + public function handle(Event $event): void { + if (!$event instanceof SabrePluginAddEvent) { + return; + } + $event->getServer()->addPlugin(new ACLPlugin( + $this->ruleManager, + $this->userSession, + $this->folderManager, + $this->eventDispatcher, + $this->aclManagerFactory, + $this->l10n + )); + } +} diff --git a/lib/Listeners/PropFindPluginListener.php b/lib/Listeners/PropFindPluginListener.php new file mode 100644 index 000000000..243f0c2c2 --- /dev/null +++ b/lib/Listeners/PropFindPluginListener.php @@ -0,0 +1,38 @@ + + */ +class PropFindPluginListener implements IEventListener { + public function __construct( + private IRootFolder $rootFolder, + private IUserSession $userSession, + ) { + } + + public function handle(Event $event): void { + if (!$event instanceof SabrePluginAddEvent) { + return; + } + $event->getServer()->addPlugin(new PropFindPlugin( + $this->rootFolder, + $this->userSession + )); + } +} diff --git a/psalm.xml b/psalm.xml index 54a6f6d26..0355b77d6 100644 --- a/psalm.xml +++ b/psalm.xml @@ -85,6 +85,7 @@ + diff --git a/tests/stubs/oca_dav_events_sabreplugaddevent.php b/tests/stubs/oca_dav_events_sabreplugaddevent.php new file mode 100644 index 000000000..454d42fad --- /dev/null +++ b/tests/stubs/oca_dav_events_sabreplugaddevent.php @@ -0,0 +1,20 @@ +