mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
fix(dispatcher): Migrate to OCP event dispatcher before symfony/event-dispatcher upgrade
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
5591da0b33
commit
6d076c1ee9
5 changed files with 15 additions and 9 deletions
|
|
@ -34,9 +34,9 @@ use OCP\AppFramework\App;
|
|||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
use OCP\AppFramework\IAppContainer;
|
||||
use OCP\IUser;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
|
|
@ -56,8 +56,8 @@ class Application extends App implements IBootstrap {
|
|||
/**
|
||||
* @todo move the OCP events and then move the registration to `register`
|
||||
*/
|
||||
private function registerEventListeners(EventDispatcher $dispatcher,
|
||||
IAppContainer $appContainer): void {
|
||||
private function registerEventListeners(EventDispatcherInterface $dispatcher,
|
||||
ContainerInterface $appContainer): void {
|
||||
$dispatcher->addListener('OC\AccountManager::userUpdated', function (GenericEvent $event) use ($appContainer) {
|
||||
/** @var IUser $user */
|
||||
$user = $event->getSubject();
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ use OCP\AppFramework\App;
|
|||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\SystemTag\ManagerEvent;
|
||||
use OCP\SystemTag\MapperEvent;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
public const APP_ID = 'systemtags';
|
||||
|
|
@ -47,7 +47,7 @@ class Application extends App implements IBootstrap {
|
|||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
$context->injectFn(function (EventDispatcher $dispatcher) use ($context) {
|
||||
$context->injectFn(function (IEventDispatcher $dispatcher) use ($context) {
|
||||
/*
|
||||
* @todo move the OCP events and then move the registration to `register`
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -113,8 +113,7 @@ class SymfonyAdapter implements EventDispatcherInterface {
|
|||
|
||||
// Event with no payload (object) need special handling
|
||||
if ($newEvent === null) {
|
||||
$this->eventDispatcher->getSymfonyDispatcher()->dispatch($eventName);
|
||||
return new Event();
|
||||
$newEvent = new Event();
|
||||
}
|
||||
|
||||
// Flip the argument order for Symfony to prevent a trigger_error
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ class SymfonyAdapterTest extends TestCase {
|
|||
$symfonyDispatcher->expects(self::once())
|
||||
->method('dispatch')
|
||||
->with(
|
||||
$this->anything(),
|
||||
$eventName
|
||||
)
|
||||
->willReturnArgument(0);
|
||||
|
|
|
|||
|
|
@ -23,12 +23,15 @@
|
|||
|
||||
namespace Test\Share20;
|
||||
|
||||
use OC\EventDispatcher\SymfonyAdapter;
|
||||
use OC\Share20\LegacyHooks;
|
||||
use OC\Share20\Manager;
|
||||
use OCP\Constants;
|
||||
use OCP\Files\Cache\ICacheEntry;
|
||||
use OCP\Files\File;
|
||||
use OCP\IServerContainer;
|
||||
use OCP\Share\IShare;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
use Test\TestCase;
|
||||
|
|
@ -46,7 +49,10 @@ class LegacyHooksTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->eventDispatcher = new EventDispatcher();
|
||||
$symfonyDispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$eventDispatcher = new \OC\EventDispatcher\EventDispatcher($symfonyDispatcher, \OC::$server->get(IServerContainer::class), $logger);
|
||||
$this->eventDispatcher = new SymfonyAdapter($eventDispatcher, $logger);
|
||||
$this->hooks = new LegacyHooks($this->eventDispatcher);
|
||||
$this->manager = \OC::$server->getShareManager();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue