Merge pull request #18256 from nextcloud/files-aditional-scripts-new-events

Use non-depricated events for loading additional scripts in files app
This commit is contained in:
Roeland Jago Douma 2019-12-09 21:24:55 +01:00 committed by GitHub
commit 0360ab408e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 5 deletions

View File

@ -30,7 +30,7 @@ use OC\EventDispatcher\SymfonyAdapter;
use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCP\EventDispatcher\Event; use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener; use OCP\EventDispatcher\IEventListener;
use Symfony\Component\EventDispatcher\GenericEvent; use OCP\EventDispatcher\GenericEvent;
class LegacyLoadAdditionalScriptsAdapter implements IEventListener { class LegacyLoadAdditionalScriptsAdapter implements IEventListener {

View File

@ -31,6 +31,7 @@ use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Backend\Backend; use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Lib\Config\IAuthMechanismProvider; use OCA\Files_External\Lib\Config\IAuthMechanismProvider;
use OCA\Files_External\Lib\Config\IBackendProvider; use OCA\Files_External\Lib\Config\IBackendProvider;
use OCP\EventDispatcher\GenericEvent;
use OCP\IConfig; use OCP\IConfig;
/** /**
@ -111,7 +112,8 @@ class BackendService {
static $eventSent = false; static $eventSent = false;
if(!$eventSent) { if(!$eventSent) {
\OC::$server->getEventDispatcher()->dispatch( \OC::$server->getEventDispatcher()->dispatch(
'OCA\\Files_External::loadAdditionalBackends' 'OCA\\Files_External::loadAdditionalBackends',
new GenericEvent()
); );
$eventSent = true; $eventSent = true;
} }

View File

@ -22,6 +22,7 @@
*/ */
use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar; use OCA\Files\Event\LoadSidebar;
use OCP\EventDispatcher\GenericEvent;
// Check if we are a user // Check if we are a user
OCP\User::checkLoggedIn(); OCP\User::checkLoggedIn();
@ -38,7 +39,7 @@ $tmpl = new OCP\Template('files_sharing', 'list', '');
$tmpl->assign('showgridview', $showgridview && !$isIE); $tmpl->assign('showgridview', $showgridview && !$isIE);
// fire script events // fire script events
$eventDispatcher->dispatch('\OCP\Collaboration\Resources::loadAdditionalScripts'); $eventDispatcher->dispatch('\OCP\Collaboration\Resources::loadAdditionalScripts', new GenericEvent());
$eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, new LoadAdditionalScriptsEvent()); $eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, new LoadAdditionalScriptsEvent());
$eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar()); $eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar());

View File

@ -31,6 +31,7 @@ use OCP\AppFramework\Http\StandaloneTemplateResponse;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Middleware; use OCP\AppFramework\Middleware;
use OCP\AppFramework\PublicShareController; use OCP\AppFramework\PublicShareController;
use OCP\EventDispatcher\GenericEvent;
use OCP\IUserSession; use OCP\IUserSession;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@ -55,10 +56,10 @@ class AdditionalScriptsMiddleware extends Middleware {
} }
if ($response instanceof TemplateResponse) { if ($response instanceof TemplateResponse) {
$this->dispatcher->dispatch(TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS); $this->dispatcher->dispatch(TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS, new GenericEvent());
if (!($response instanceof StandaloneTemplateResponse) && $this->userSession->isLoggedIn()) { if (!($response instanceof StandaloneTemplateResponse) && $this->userSession->isLoggedIn()) {
$this->dispatcher->dispatch(TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN); $this->dispatcher->dispatch(TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN, new GenericEvent());
} }
} }