Assertion.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Support\Subscription;
  8. use OCP\HintException;
  9. use OCP\L10N\IFactory;
  10. use OCP\Notification\IManager;
  11. use OCP\Support\Subscription\IAssertion;
  12. use OCP\Support\Subscription\IRegistry;
  13. class Assertion implements IAssertion {
  14. private IRegistry $registry;
  15. private IFactory $l10nFactory;
  16. private IManager $notificationManager;
  17. public function __construct(IRegistry $registry, IFactory $l10nFactory, IManager $notificationManager) {
  18. $this->registry = $registry;
  19. $this->l10nFactory = $l10nFactory;
  20. $this->notificationManager = $notificationManager;
  21. }
  22. /**
  23. * @inheritDoc
  24. */
  25. public function createUserIsLegit(): void {
  26. if ($this->registry->delegateIsHardUserLimitReached($this->notificationManager)) {
  27. $l = $this->l10nFactory->get('lib');
  28. throw new HintException($l->t('The user was not created because the user limit has been reached. Check your notifications to learn more.'));
  29. }
  30. }
  31. }