BundleFetcher.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OC\App\AppStore\Bundles;
  7. use OCP\IL10N;
  8. class BundleFetcher {
  9. public function __construct(
  10. private IL10N $l10n,
  11. ) {
  12. }
  13. /**
  14. * @return Bundle[]
  15. */
  16. public function getBundles(): array {
  17. return [
  18. new EnterpriseBundle($this->l10n),
  19. new HubBundle($this->l10n),
  20. new GroupwareBundle($this->l10n),
  21. new SocialSharingBundle($this->l10n),
  22. new EducationBundle($this->l10n),
  23. new PublicSectorBundle($this->l10n),
  24. ];
  25. }
  26. /**
  27. * Get the bundle with the specified identifier
  28. *
  29. * @param string $identifier
  30. * @return Bundle
  31. * @throws \BadMethodCallException If the bundle does not exist
  32. */
  33. public function getBundleByIdentifier(string $identifier): Bundle {
  34. foreach ($this->getBundles() as $bundle) {
  35. if ($bundle->getIdentifier() === $identifier) {
  36. return $bundle;
  37. }
  38. }
  39. throw new \BadMethodCallException('Bundle with specified identifier does not exist');
  40. }
  41. }