Merge pull request #1045 from nextcloud/feature/noid/createThirdPartyHook

Allow thirdparty apps to hook the calendar app
This commit is contained in:
Georg Ehrke 2019-09-13 12:47:03 +00:00 committed by GitHub
commit 15a5d491c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -82,8 +82,9 @@ class Application extends App {
$userSession = $c->getServer()->getUserSession();
$config = $c->getServer()->getConfig();
$urlGenerator = $c->getServer()->getURLGenerator();
$eventDispatcher = $c->getServer()->getEventDispatcher();
return new Controller\ViewController($c->getAppName(), $request, $userSession, $config, $urlGenerator);
return new Controller\ViewController($c->getAppName(), $request, $userSession, $config, $urlGenerator, $eventDispatcher);
});
}

View File

@ -31,6 +31,8 @@ use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\IURLGenerator;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
class ViewController extends Controller {
@ -48,20 +50,27 @@ class ViewController extends Controller {
* @var IUserSession
*/
private $userSession;
/**
* @var EventDispatcherInterface
*/
private $eventDispatcher;
/**
* @param string $appName
* @param IRequest $request an instance of the request
* @param IUserSession $userSession
* @param IConfig $config
* @param IURLGenerator $urlGenerator
* @param EventDispatcherInterface $eventDispatcherInterface
*/
public function __construct($appName, IRequest $request, IUserSession $userSession,
IConfig $config, IURLGenerator $urlGenerator) {
IConfig $config, IURLGenerator $urlGenerator, EventDispatcherInterface $eventDispatcherInterface) {
parent::__construct($appName, $request);
$this->config = $config;
$this->userSession = $userSession;
$this->urlGenerator = $urlGenerator;
$this->eventDispatcher = $eventDispatcherInterface;
}
/**
@ -99,6 +108,8 @@ class ViewController extends Controller {
$initialView = 'month';
}
$this->eventDispatcher->dispatch('OCA\Calendar::loadAdditionalScripts');
return new TemplateResponse('calendar', 'main', array_merge($templateParameters, [
'initialView' => $initialView,
'emailAddress' => $emailAddress,