From 0b64268910a0fc681f1b2b6a154e08af2818b379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 14 Aug 2015 15:40:15 +0200 Subject: [PATCH 1/2] Adding EventDispatcher to IServerContainer --- lib/private/server.php | 17 +++++++++++++++-- lib/public/iservercontainer.php | 9 +++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/private/server.php b/lib/private/server.php index 618431ff2d..8900156721 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -51,7 +51,6 @@ use OC\Http\Client\ClientService; use OC\Lock\MemcacheLockingProvider; use OC\Lock\NoopLockingProvider; use OC\Mail\Mailer; -use OC\Memcache\NullCache; use OC\Security\CertificateManager; use OC\Security\Crypto; use OC\Security\Hasher; @@ -59,6 +58,8 @@ use OC\Security\SecureRandom; use OC\Security\TrustedDomainHelper; use OC\Tagging\TagMapper; use OCP\IServerContainer; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class Server @@ -457,7 +458,9 @@ class Server extends SimpleContainer implements IServerContainer { }); return $manager; }); - + $this->registerService('EventDispatcher', function() { + return new EventDispatcher(); + }); } /** @@ -963,4 +966,14 @@ class Server extends SimpleContainer implements IServerContainer { public function getCapabilitiesManager() { return $this->query('CapabilitiesManager'); } + + /** + * Get the EventDispatcher + * + * @return EventDispatcherInterface + * @since 8.2.0 + */ + public function getEventDispatcher() { + return $this->query('EventDispatcher'); + } } diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index ab1729da25..a6d83156de 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -39,6 +39,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes namespace OCP; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -439,4 +440,12 @@ interface IServerContainer { */ public function getMimeTypeDetector(); + + /** + * Get the EventDispatcher + * + * @return EventDispatcherInterface + * @since 8.2.0 + */ + public function getEventDispatcher(); } From dfba425d68f350ec8b7d7aebc8746b98476fb5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 14 Aug 2015 15:41:08 +0200 Subject: [PATCH 2/2] Integration in files app to load scripts and styles on request --- apps/files/index.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/files/index.php b/apps/files/index.php index beae585cea..a73caa50fb 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -143,6 +143,9 @@ OCP\Util::addscript('files', 'fileactionsmenu'); OCP\Util::addscript('files', 'files'); OCP\Util::addscript('files', 'navigation'); OCP\Util::addscript('files', 'keyboardshortcuts'); + +\OC::$server->getEventDispatcher()->dispatch('OCA\Files::loadAdditionalScripts'); + $tmpl = new OCP\Template('files', 'index', 'user'); $tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']); $tmpl->assign('owner', $storageInfo['owner']);