ManagerFactory.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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\IServerContainer;
  27. use OCP\SystemTag\ISystemTagManager;
  28. use OCP\SystemTag\ISystemTagManagerFactory;
  29. use OCP\SystemTag\ISystemTagObjectMapper;
  30. /**
  31. * Default factory class for system tag managers
  32. *
  33. * @package OCP\SystemTag
  34. * @since 9.0.0
  35. */
  36. class ManagerFactory implements ISystemTagManagerFactory {
  37. /**
  38. * Server container
  39. *
  40. * @var IServerContainer
  41. */
  42. private $serverContainer;
  43. /**
  44. * Constructor for the system tag manager factory
  45. *
  46. * @param IServerContainer $serverContainer server container
  47. */
  48. public function __construct(IServerContainer $serverContainer) {
  49. $this->serverContainer = $serverContainer;
  50. }
  51. /**
  52. * Creates and returns an instance of the system tag manager
  53. *
  54. * @return ISystemTagManager
  55. * @since 9.0.0
  56. */
  57. public function getManager(): ISystemTagManager {
  58. return new SystemTagManager(
  59. $this->serverContainer->getDatabaseConnection(),
  60. $this->serverContainer->getGroupManager(),
  61. $this->serverContainer->getEventDispatcher()
  62. );
  63. }
  64. /**
  65. * Creates and returns an instance of the system tag object
  66. * mapper
  67. *
  68. * @return ISystemTagObjectMapper
  69. * @since 9.0.0
  70. */
  71. public function getObjectMapper(): ISystemTagObjectMapper {
  72. return new SystemTagObjectMapper(
  73. $this->serverContainer->getDatabaseConnection(),
  74. $this->getManager(),
  75. $this->serverContainer->getEventDispatcher()
  76. );
  77. }
  78. }