1
0

ProfileConfigMapper.php 824 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Core\Db;
  8. use OCP\AppFramework\Db\QBMapper;
  9. use OCP\IDBConnection;
  10. /**
  11. * @template-extends QBMapper<ProfileConfig>
  12. */
  13. class ProfileConfigMapper extends QBMapper {
  14. public function __construct(IDBConnection $db) {
  15. parent::__construct($db, 'profile_config', ProfileConfig::class);
  16. }
  17. public function get(string $userId): ProfileConfig {
  18. $qb = $this->db->getQueryBuilder();
  19. $qb->select('*')
  20. ->from($this->getTableName())
  21. ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
  22. return $this->findEntity($qb);
  23. }
  24. public function getArray(string $userId): array {
  25. return $this->get($userId)->getConfigArray();
  26. }
  27. }