aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-07-25 11:58:47 +0200
committerJoas Schilling <coding@schilljs.com>2023-07-27 09:57:52 +0200
commit6953e14580ddc94a11cf4f420f38dae2d1ae2917 (patch)
tree9d15b7e2688299f63750bff9edc2a9f135a96fb9
parentdac31ad1010924bc2067fbbdaf5c856639c71091 (diff)
downloadnextcloud-server-6953e14580ddc94a11cf4f420f38dae2d1ae2917.tar.gz
nextcloud-server-6953e14580ddc94a11cf4f420f38dae2d1ae2917.zip
fix: Move SystemTags events to IEventDispatcher
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/private/SystemTag/ManagerFactory.php5
-rw-r--r--lib/private/SystemTag/SystemTagManager.php28
-rw-r--r--lib/private/SystemTag/SystemTagObjectMapper.php27
-rw-r--r--tests/lib/SystemTag/SystemTagManagerTest.php10
-rw-r--r--tests/lib/SystemTag/SystemTagObjectMapperTest.php11
5 files changed, 21 insertions, 60 deletions
diff --git a/lib/private/SystemTag/ManagerFactory.php b/lib/private/SystemTag/ManagerFactory.php
index ca0508fe19b..6670922407e 100644
--- a/lib/private/SystemTag/ManagerFactory.php
+++ b/lib/private/SystemTag/ManagerFactory.php
@@ -26,6 +26,7 @@ declare(strict_types=1);
*/
namespace OC\SystemTag;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IServerContainer;
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ISystemTagManagerFactory;
@@ -64,7 +65,7 @@ class ManagerFactory implements ISystemTagManagerFactory {
return new SystemTagManager(
$this->serverContainer->getDatabaseConnection(),
$this->serverContainer->getGroupManager(),
- $this->serverContainer->getEventDispatcher()
+ $this->serverContainer->get(IEventDispatcher::class),
);
}
@@ -79,7 +80,7 @@ class ManagerFactory implements ISystemTagManagerFactory {
return new SystemTagObjectMapper(
$this->serverContainer->getDatabaseConnection(),
$this->getManager(),
- $this->serverContainer->getEventDispatcher()
+ $this->serverContainer->get(IEventDispatcher::class),
);
}
}
diff --git a/lib/private/SystemTag/SystemTagManager.php b/lib/private/SystemTag/SystemTagManager.php
index 65046ebf000..a2285752361 100644
--- a/lib/private/SystemTag/SystemTagManager.php
+++ b/lib/private/SystemTag/SystemTagManager.php
@@ -31,6 +31,7 @@ namespace OC\SystemTag;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IUser;
@@ -39,7 +40,6 @@ use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ManagerEvent;
use OCP\SystemTag\TagAlreadyExistsException;
use OCP\SystemTag\TagNotFoundException;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Manager class for system tags
@@ -48,15 +48,6 @@ class SystemTagManager implements ISystemTagManager {
public const TAG_TABLE = 'systemtag';
public const TAG_GROUP_TABLE = 'systemtag_group';
- /** @var IDBConnection */
- protected $connection;
-
- /** @var EventDispatcherInterface */
- protected $dispatcher;
-
- /** @var IGroupManager */
- protected $groupManager;
-
/**
* Prepared query for selecting tags directly
*
@@ -64,22 +55,11 @@ class SystemTagManager implements ISystemTagManager {
*/
private $selectTagQuery;
- /**
- * Constructor.
- *
- * @param IDBConnection $connection database connection
- * @param IGroupManager $groupManager
- * @param EventDispatcherInterface $dispatcher
- */
public function __construct(
- IDBConnection $connection,
- IGroupManager $groupManager,
- EventDispatcherInterface $dispatcher
+ protected IDBConnection $connection,
+ protected IGroupManager $groupManager,
+ protected IEventDispatcher $dispatcher,
) {
- $this->connection = $connection;
- $this->groupManager = $groupManager;
- $this->dispatcher = $dispatcher;
-
$query = $this->connection->getQueryBuilder();
$this->selectTagQuery = $query->select('*')
->from(self::TAG_TABLE)
diff --git a/lib/private/SystemTag/SystemTagObjectMapper.php b/lib/private/SystemTag/SystemTagObjectMapper.php
index 864ba3e91a8..66a21e58609 100644
--- a/lib/private/SystemTag/SystemTagObjectMapper.php
+++ b/lib/private/SystemTag/SystemTagObjectMapper.php
@@ -29,37 +29,22 @@ namespace OC\SystemTag;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IDBConnection;
use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ISystemTagObjectMapper;
use OCP\SystemTag\MapperEvent;
use OCP\SystemTag\TagNotFoundException;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class SystemTagObjectMapper implements ISystemTagObjectMapper {
public const RELATION_TABLE = 'systemtag_object_mapping';
- /** @var ISystemTagManager */
- protected $tagManager;
-
- /** @var IDBConnection */
- protected $connection;
-
- /** @var EventDispatcherInterface */
- protected $dispatcher;
-
- /**
- * Constructor.
- *
- * @param IDBConnection $connection database connection
- * @param ISystemTagManager $tagManager system tag manager
- * @param EventDispatcherInterface $dispatcher
- */
- public function __construct(IDBConnection $connection, ISystemTagManager $tagManager, EventDispatcherInterface $dispatcher) {
- $this->connection = $connection;
- $this->tagManager = $tagManager;
- $this->dispatcher = $dispatcher;
+ public function __construct(
+ protected IDBConnection $connection,
+ protected ISystemTagManager $tagManager,
+ protected IEventDispatcher $dispatcher,
+ ) {
}
/**
diff --git a/tests/lib/SystemTag/SystemTagManagerTest.php b/tests/lib/SystemTag/SystemTagManagerTest.php
index e261a68aaf7..e4610ede9bf 100644
--- a/tests/lib/SystemTag/SystemTagManagerTest.php
+++ b/tests/lib/SystemTag/SystemTagManagerTest.php
@@ -12,12 +12,12 @@ namespace Test\SystemTag;
use OC\SystemTag\SystemTagManager;
use OC\SystemTag\SystemTagObjectMapper;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Test\TestCase;
/**
@@ -43,7 +43,7 @@ class SystemTagManagerTest extends TestCase {
private $groupManager;
/**
- * @var EventDispatcherInterface
+ * @var IEventDispatcher
*/
private $dispatcher;
@@ -52,10 +52,8 @@ class SystemTagManagerTest extends TestCase {
$this->connection = \OC::$server->getDatabaseConnection();
- $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')
- ->getMock();
-
- $this->groupManager = $this->getMockBuilder(IGroupManager::class)->getMock();
+ $this->dispatcher = $this->createMock(IEventDispatcher::class);
+ $this->groupManager = $this->createMock(IGroupManager::class);
$this->tagManager = new SystemTagManager(
$this->connection,
diff --git a/tests/lib/SystemTag/SystemTagObjectMapperTest.php b/tests/lib/SystemTag/SystemTagObjectMapperTest.php
index e77709c781f..2c838e0a6b3 100644
--- a/tests/lib/SystemTag/SystemTagObjectMapperTest.php
+++ b/tests/lib/SystemTag/SystemTagObjectMapperTest.php
@@ -13,12 +13,12 @@ namespace Test\SystemTag;
use OC\SystemTag\SystemTag;
use OC\SystemTag\SystemTagManager;
use OC\SystemTag\SystemTagObjectMapper;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IDBConnection;
use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ISystemTagObjectMapper;
use OCP\SystemTag\TagNotFoundException;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Test\TestCase;
/**
@@ -44,7 +44,7 @@ class SystemTagObjectMapperTest extends TestCase {
private $connection;
/**
- * @var EventDispatcherInterface
+ * @var IEventDispatcher
*/
private $dispatcher;
@@ -69,11 +69,8 @@ class SystemTagObjectMapperTest extends TestCase {
$this->connection = \OC::$server->getDatabaseConnection();
$this->pruneTagsTables();
- $this->tagManager = $this->getMockBuilder('OCP\SystemTag\ISystemTagManager')
- ->getMock();
-
- $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')
- ->getMock();
+ $this->tagManager = $this->createMock(ISystemTagManager::class);
+ $this->dispatcher = $this->createMock(IEventDispatcher::class);
$this->tagMapper = new SystemTagObjectMapper(
$this->connection,