ManagerFactory.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. * @author Vincent Petry <vincent@nextcloud.com>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OC\SystemTag;
  26. use OCP\EventDispatcher\IEventDispatcher;
  27. use OCP\IServerContainer;
  28. use OCP\SystemTag\ISystemTagManager;
  29. use OCP\SystemTag\ISystemTagManagerFactory;
  30. use OCP\SystemTag\ISystemTagObjectMapper;
  31. /**
  32. * Default factory class for system tag managers
  33. *
  34. * @package OCP\SystemTag
  35. * @since 9.0.0
  36. */
  37. class ManagerFactory implements ISystemTagManagerFactory {
  38. /**
  39. * Constructor for the system tag manager factory
  40. */
  41. public function __construct(
  42. private IServerContainer $serverContainer,
  43. ) {
  44. }
  45. /**
  46. * Creates and returns an instance of the system tag manager
  47. *
  48. * @since 9.0.0
  49. */
  50. public function getManager(): ISystemTagManager {
  51. return new SystemTagManager(
  52. $this->serverContainer->getDatabaseConnection(),
  53. $this->serverContainer->getGroupManager(),
  54. $this->serverContainer->get(IEventDispatcher::class),
  55. );
  56. }
  57. /**
  58. * Creates and returns an instance of the system tag object
  59. * mapper
  60. *
  61. * @since 9.0.0
  62. */
  63. public function getObjectMapper(): ISystemTagObjectMapper {
  64. return new SystemTagObjectMapper(
  65. $this->serverContainer->getDatabaseConnection(),
  66. $this->getManager(),
  67. $this->serverContainer->get(IEventDispatcher::class),
  68. );
  69. }
  70. }