Skip to content

Commit b425b34

Browse files
authored
Merge pull request #17575 from nextcloud/include-the-share-in-the-files_sharing-loadadditionalscripts-event
Include the share in the Files_Sharing::loadAdditionalScripts event
2 parents dd0e738 + 5c7c308 commit b425b34

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

apps/files_sharing/lib/Controller/ShareController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ public function showShare($path = ''): TemplateResponse {
445445
\OCP\Util::addHeader('meta', ['property' => "og:type", 'content' => "object"]);
446446
\OCP\Util::addHeader('meta', ['property' => "og:image", 'content' => $ogPreview]);
447447

448-
$this->eventDispatcher->dispatch('OCA\Files_Sharing::loadAdditionalScripts');
448+
$event = new GenericEvent(null, ['share' => $share]);
449+
$this->eventDispatcher->dispatch('OCA\Files_Sharing::loadAdditionalScripts', $event);
449450

450451
$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
451452
$csp->addAllowedFrameDomain('\'self\'');

apps/files_sharing/tests/Controller/ShareControllerTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,12 @@ public function testShowShare() {
254254

255255
$this->eventDispatcher->expects($this->once())
256256
->method('dispatch')
257-
->with('OCA\Files_Sharing::loadAdditionalScripts');
257+
->with(
258+
'OCA\Files_Sharing::loadAdditionalScripts',
259+
$this->callback(function($event) use ($share) {
260+
return $event->getArgument('share') === $share;
261+
})
262+
);
258263

259264
$this->l10n->expects($this->any())
260265
->method('t')
@@ -374,7 +379,12 @@ public function testShowShareHideDownload() {
374379

375380
$this->eventDispatcher->expects($this->once())
376381
->method('dispatch')
377-
->with('OCA\Files_Sharing::loadAdditionalScripts');
382+
->with(
383+
'OCA\Files_Sharing::loadAdditionalScripts',
384+
$this->callback(function($event) use ($share) {
385+
return $event->getArgument('share') === $share;
386+
})
387+
);
378388

379389
$this->l10n->expects($this->any())
380390
->method('t')

0 commit comments

Comments
 (0)