diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-07-15 15:01:14 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-07-18 13:35:35 +0200 |
commit | 1c5e082ee145815a13a0dadbc7e9fb0e49ae2f0f (patch) | |
tree | 1788a32926333f46d776159e08f1e77a4137d6d2 /apps | |
parent | ea3035aa0e2d4b58532a127c7f3dbe0b41470a33 (diff) | |
download | nextcloud-server-1c5e082ee145815a13a0dadbc7e9fb0e49ae2f0f.tar.gz nextcloud-server-1c5e082ee145815a13a0dadbc7e9fb0e49ae2f0f.zip |
Add eventdispatcher to public link view
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/AppInfo/Application.php | 3 | ||||
-rw-r--r-- | apps/files_sharing/lib/Controllers/ShareController.php | 10 | ||||
-rw-r--r-- | apps/files_sharing/tests/Controllers/ShareControllerTest.php | 11 |
3 files changed, 21 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 5ed8d886e2e..b91b0f3ef6e 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -59,7 +59,8 @@ class Application extends App { $server->getSession(), $server->getPreviewManager(), $server->getRootFolder(), - $federatedSharingApp->getFederatedShareProvider() + $federatedSharingApp->getFederatedShareProvider(), + $server->getEventDispatcher() ); }); $container->registerService('ExternalSharesController', function (SimpleContainer $c) { diff --git a/apps/files_sharing/lib/Controllers/ShareController.php b/apps/files_sharing/lib/Controllers/ShareController.php index 124d633b99f..fd4ff3f32c0 100644 --- a/apps/files_sharing/lib/Controllers/ShareController.php +++ b/apps/files_sharing/lib/Controllers/ShareController.php @@ -54,6 +54,7 @@ use OCA\Files_Sharing\Activity; use \OCP\Files\NotFoundException; use OCP\Files\IRootFolder; use OCP\Share\Exceptions\ShareNotFound; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class ShareController @@ -82,6 +83,8 @@ class ShareController extends Controller { protected $rootFolder; /** @var FederatedShareProvider */ protected $federatedShareProvider; + /** @var EventDispatcherInterface */ + protected $eventDispatcher; /** * @param string $appName @@ -96,6 +99,7 @@ class ShareController extends Controller { * @param IPreview $previewManager * @param IRootFolder $rootFolder * @param FederatedShareProvider $federatedShareProvider + * @param EventDispatcherInterface $eventDispatcher */ public function __construct($appName, IRequest $request, @@ -108,7 +112,8 @@ class ShareController extends Controller { ISession $session, IPreview $previewManager, IRootFolder $rootFolder, - FederatedShareProvider $federatedShareProvider) { + FederatedShareProvider $federatedShareProvider, + EventDispatcherInterface $eventDispatcher) { parent::__construct($appName, $request); $this->config = $config; @@ -121,6 +126,7 @@ class ShareController extends Controller { $this->previewManager = $previewManager; $this->rootFolder = $rootFolder; $this->federatedShareProvider = $federatedShareProvider; + $this->eventDispatcher = $eventDispatcher; } /** @@ -376,6 +382,8 @@ class ShareController extends Controller { OCP\Util::addscript('files', 'keyboardshortcuts'); } + $this->eventDispatcher->dispatch('OCA\Files_Sharing::loadAdditionalScripts'); + $csp = new OCP\AppFramework\Http\ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); $response = new TemplateResponse($this->appName, 'public', $shareTmpl, 'base'); diff --git a/apps/files_sharing/tests/Controllers/ShareControllerTest.php b/apps/files_sharing/tests/Controllers/ShareControllerTest.php index 343d5c58d69..5b856198742 100644 --- a/apps/files_sharing/tests/Controllers/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controllers/ShareControllerTest.php @@ -41,6 +41,7 @@ use OCP\ISession; use OCP\IUserManager; use OCP\Security\ISecureRandom; use OCP\IURLGenerator; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * @group DB @@ -72,6 +73,8 @@ class ShareControllerTest extends \Test\TestCase { private $userManager; /** @var FederatedShareProvider | \PHPUnit_Framework_MockObject_MockObject */ private $federatedShareProvider; + /** @var EventDispatcherInterface | \PHPUnit_Framework_MockObject_MockObject */ + private $eventDispatcher; protected function setUp() { parent::setUp(); @@ -89,6 +92,7 @@ class ShareControllerTest extends \Test\TestCase { ->method('isOutgoingServer2serverShareEnabled')->willReturn(true); $this->federatedShareProvider->expects($this->any()) ->method('isIncomingServer2serverShareEnabled')->willReturn(true); + $this->eventDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $this->shareController = new \OCA\Files_Sharing\Controllers\ShareController( $this->appName, @@ -102,7 +106,8 @@ class ShareControllerTest extends \Test\TestCase { $this->session, $this->previewManager, $this->getMockBuilder('\OCP\Files\IRootFolder')->getMock(), - $this->federatedShareProvider + $this->federatedShareProvider, + $this->eventDispatcher ); @@ -353,6 +358,10 @@ class ShareControllerTest extends \Test\TestCase { $this->userManager->method('get')->with('ownerUID')->willReturn($owner); + $this->eventDispatcher->expects($this->once()) + ->method('dispatch') + ->with('OCA\Files_Sharing::loadAdditionalScripts'); + $response = $this->shareController->showShare('token'); $sharedTmplParams = array( 'displayName' => 'ownerDisplay', |