@@ -34,49 +34,49 @@ |
||
34 | 34 | * Mapper for Tag entity |
35 | 35 | */ |
36 | 36 | class TagMapper extends QBMapper { |
37 | - /** |
|
38 | - * Constructor. |
|
39 | - * |
|
40 | - * @param IDBConnection $db Instance of the Db abstraction layer. |
|
41 | - */ |
|
42 | - public function __construct(IDBConnection $db) { |
|
43 | - parent::__construct($db, 'vcategory', Tag::class); |
|
44 | - } |
|
37 | + /** |
|
38 | + * Constructor. |
|
39 | + * |
|
40 | + * @param IDBConnection $db Instance of the Db abstraction layer. |
|
41 | + */ |
|
42 | + public function __construct(IDBConnection $db) { |
|
43 | + parent::__construct($db, 'vcategory', Tag::class); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Load tags from the database. |
|
48 | - * |
|
49 | - * @param array $owners The user(s) whose tags we are going to load. |
|
50 | - * @param string $type The type of item for which we are loading tags. |
|
51 | - * @return array An array of Tag objects. |
|
52 | - */ |
|
53 | - public function loadTags(array $owners, string $type): array { |
|
54 | - $qb = $this->db->getQueryBuilder(); |
|
55 | - $qb->select(['id', 'uid', 'type', 'category']) |
|
56 | - ->from($this->getTableName()) |
|
57 | - ->where($qb->expr()->in('uid', $qb->createNamedParameter($owners, IQueryBuilder::PARAM_STR_ARRAY))) |
|
58 | - ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($type, IQueryBuilder::PARAM_STR))) |
|
59 | - ->orderBy('category'); |
|
60 | - return $this->findEntities($qb); |
|
61 | - } |
|
46 | + /** |
|
47 | + * Load tags from the database. |
|
48 | + * |
|
49 | + * @param array $owners The user(s) whose tags we are going to load. |
|
50 | + * @param string $type The type of item for which we are loading tags. |
|
51 | + * @return array An array of Tag objects. |
|
52 | + */ |
|
53 | + public function loadTags(array $owners, string $type): array { |
|
54 | + $qb = $this->db->getQueryBuilder(); |
|
55 | + $qb->select(['id', 'uid', 'type', 'category']) |
|
56 | + ->from($this->getTableName()) |
|
57 | + ->where($qb->expr()->in('uid', $qb->createNamedParameter($owners, IQueryBuilder::PARAM_STR_ARRAY))) |
|
58 | + ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($type, IQueryBuilder::PARAM_STR))) |
|
59 | + ->orderBy('category'); |
|
60 | + return $this->findEntities($qb); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Check if a given Tag object already exists in the database. |
|
65 | - * |
|
66 | - * @param Tag $tag The tag to look for in the database. |
|
67 | - */ |
|
68 | - public function tagExists(Tag $tag): bool { |
|
69 | - $qb = $this->db->getQueryBuilder(); |
|
70 | - $qb->select(['id', 'uid', 'type', 'category']) |
|
71 | - ->from($this->getTableName()) |
|
72 | - ->where($qb->expr()->eq('uid', $qb->createNamedParameter($tag->getOwner(), IQueryBuilder::PARAM_STR))) |
|
73 | - ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($tag->getType(), IQueryBuilder::PARAM_STR))) |
|
74 | - ->andWhere($qb->expr()->eq('category', $qb->createNamedParameter($tag->getName(), IQueryBuilder::PARAM_STR))); |
|
75 | - try { |
|
76 | - $this->findEntity($qb); |
|
77 | - } catch (DoesNotExistException $e) { |
|
78 | - return false; |
|
79 | - } |
|
80 | - return true; |
|
81 | - } |
|
63 | + /** |
|
64 | + * Check if a given Tag object already exists in the database. |
|
65 | + * |
|
66 | + * @param Tag $tag The tag to look for in the database. |
|
67 | + */ |
|
68 | + public function tagExists(Tag $tag): bool { |
|
69 | + $qb = $this->db->getQueryBuilder(); |
|
70 | + $qb->select(['id', 'uid', 'type', 'category']) |
|
71 | + ->from($this->getTableName()) |
|
72 | + ->where($qb->expr()->eq('uid', $qb->createNamedParameter($tag->getOwner(), IQueryBuilder::PARAM_STR))) |
|
73 | + ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($tag->getType(), IQueryBuilder::PARAM_STR))) |
|
74 | + ->andWhere($qb->expr()->eq('category', $qb->createNamedParameter($tag->getName(), IQueryBuilder::PARAM_STR))); |
|
75 | + try { |
|
76 | + $this->findEntity($qb); |
|
77 | + } catch (DoesNotExistException $e) { |
|
78 | + return false; |
|
79 | + } |
|
80 | + return true; |
|
81 | + } |
|
82 | 82 | } |