Add eventdispatcher to public link view
This commit is contained in:
parent
ea3035aa0e
commit
1c5e082ee1
3 changed files with 21 additions and 3 deletions
|
@ -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) {
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue