@@ -18,68 +18,68 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class PropertyMapper extends QBMapper { |
| 20 | 20 | |
| 21 | - private const TABLE_NAME = 'properties'; |
|
| 21 | + private const TABLE_NAME = 'properties'; |
|
| 22 | 22 | |
| 23 | - public function __construct(IDBConnection $db) { |
|
| 24 | - parent::__construct($db, self::TABLE_NAME, Property::class); |
|
| 25 | - } |
|
| 23 | + public function __construct(IDBConnection $db) { |
|
| 24 | + parent::__construct($db, self::TABLE_NAME, Property::class); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @return Property[] |
|
| 29 | - */ |
|
| 30 | - public function findPropertyByPathAndName(string $userId, string $path, string $name): array { |
|
| 31 | - $selectQb = $this->db->getQueryBuilder(); |
|
| 32 | - $selectQb->select('*') |
|
| 33 | - ->from(self::TABLE_NAME) |
|
| 34 | - ->where( |
|
| 35 | - $selectQb->expr()->eq('userid', $selectQb->createNamedParameter($userId)), |
|
| 36 | - $selectQb->expr()->eq('propertypath', $selectQb->createNamedParameter($path)), |
|
| 37 | - $selectQb->expr()->eq('propertyname', $selectQb->createNamedParameter($name)), |
|
| 38 | - ); |
|
| 39 | - return $this->findEntities($selectQb); |
|
| 40 | - } |
|
| 27 | + /** |
|
| 28 | + * @return Property[] |
|
| 29 | + */ |
|
| 30 | + public function findPropertyByPathAndName(string $userId, string $path, string $name): array { |
|
| 31 | + $selectQb = $this->db->getQueryBuilder(); |
|
| 32 | + $selectQb->select('*') |
|
| 33 | + ->from(self::TABLE_NAME) |
|
| 34 | + ->where( |
|
| 35 | + $selectQb->expr()->eq('userid', $selectQb->createNamedParameter($userId)), |
|
| 36 | + $selectQb->expr()->eq('propertypath', $selectQb->createNamedParameter($path)), |
|
| 37 | + $selectQb->expr()->eq('propertyname', $selectQb->createNamedParameter($name)), |
|
| 38 | + ); |
|
| 39 | + return $this->findEntities($selectQb); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @param array<string, string[]> $calendars |
|
| 44 | - * @return Property[] |
|
| 45 | - * @throws \OCP\DB\Exception |
|
| 46 | - */ |
|
| 47 | - public function findPropertiesByPathsAndUsers(array $calendars): array { |
|
| 48 | - if (empty($calendars)) { |
|
| 49 | - return []; |
|
| 50 | - } |
|
| 51 | - $selectQb = $this->db->getQueryBuilder(); |
|
| 52 | - $selectQb->select('*') |
|
| 53 | - ->from(self::TABLE_NAME); |
|
| 42 | + /** |
|
| 43 | + * @param array<string, string[]> $calendars |
|
| 44 | + * @return Property[] |
|
| 45 | + * @throws \OCP\DB\Exception |
|
| 46 | + */ |
|
| 47 | + public function findPropertiesByPathsAndUsers(array $calendars): array { |
|
| 48 | + if (empty($calendars)) { |
|
| 49 | + return []; |
|
| 50 | + } |
|
| 51 | + $selectQb = $this->db->getQueryBuilder(); |
|
| 52 | + $selectQb->select('*') |
|
| 53 | + ->from(self::TABLE_NAME); |
|
| 54 | 54 | |
| 55 | - foreach ($calendars as $user => $paths) { |
|
| 56 | - $selectQb->orWhere( |
|
| 57 | - $selectQb->expr()->andX( |
|
| 58 | - $selectQb->expr()->eq('userid', $selectQb->createNamedParameter($user)), |
|
| 59 | - $selectQb->expr()->in('propertypath', $selectQb->createNamedParameter($paths, IQueryBuilder::PARAM_STR_ARRAY)), |
|
| 60 | - ) |
|
| 61 | - ); |
|
| 62 | - } |
|
| 55 | + foreach ($calendars as $user => $paths) { |
|
| 56 | + $selectQb->orWhere( |
|
| 57 | + $selectQb->expr()->andX( |
|
| 58 | + $selectQb->expr()->eq('userid', $selectQb->createNamedParameter($user)), |
|
| 59 | + $selectQb->expr()->in('propertypath', $selectQb->createNamedParameter($paths, IQueryBuilder::PARAM_STR_ARRAY)), |
|
| 60 | + ) |
|
| 61 | + ); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return $this->findEntities($selectQb); |
|
| 65 | - } |
|
| 64 | + return $this->findEntities($selectQb); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @param string[] $calendars |
|
| 69 | - * @param string[] $allowedProperties |
|
| 70 | - * @return Property[] |
|
| 71 | - * @throws \OCP\DB\Exception |
|
| 72 | - */ |
|
| 73 | - public function findPropertiesByPaths(array $calendars, array $allowedProperties = []): array { |
|
| 74 | - $selectQb = $this->db->getQueryBuilder(); |
|
| 75 | - $selectQb->select('*') |
|
| 76 | - ->from(self::TABLE_NAME) |
|
| 77 | - ->where($selectQb->expr()->in('propertypath', $selectQb->createNamedParameter($calendars, IQueryBuilder::PARAM_STR_ARRAY))); |
|
| 67 | + /** |
|
| 68 | + * @param string[] $calendars |
|
| 69 | + * @param string[] $allowedProperties |
|
| 70 | + * @return Property[] |
|
| 71 | + * @throws \OCP\DB\Exception |
|
| 72 | + */ |
|
| 73 | + public function findPropertiesByPaths(array $calendars, array $allowedProperties = []): array { |
|
| 74 | + $selectQb = $this->db->getQueryBuilder(); |
|
| 75 | + $selectQb->select('*') |
|
| 76 | + ->from(self::TABLE_NAME) |
|
| 77 | + ->where($selectQb->expr()->in('propertypath', $selectQb->createNamedParameter($calendars, IQueryBuilder::PARAM_STR_ARRAY))); |
|
| 78 | 78 | |
| 79 | - if ($allowedProperties) { |
|
| 80 | - $selectQb->andWhere($selectQb->expr()->in('propertyname', $selectQb->createNamedParameter($allowedProperties, IQueryBuilder::PARAM_STR_ARRAY))); |
|
| 81 | - } |
|
| 79 | + if ($allowedProperties) { |
|
| 80 | + $selectQb->andWhere($selectQb->expr()->in('propertyname', $selectQb->createNamedParameter($allowedProperties, IQueryBuilder::PARAM_STR_ARRAY))); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - return $this->findEntities($selectQb); |
|
| 84 | - } |
|
| 83 | + return $this->findEntities($selectQb); |
|
| 84 | + } |
|
| 85 | 85 | } |