BundleFetcher.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Lukas Reschke <lukas@statuscode.ch>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  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
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OC\App\AppStore\Bundles;
  26. use OCP\IL10N;
  27. class BundleFetcher {
  28. private IL10N $l10n;
  29. public function __construct(IL10N $l10n) {
  30. $this->l10n = $l10n;
  31. }
  32. /**
  33. * @return Bundle[]
  34. */
  35. public function getBundles(): array {
  36. return [
  37. new EnterpriseBundle($this->l10n),
  38. new HubBundle($this->l10n),
  39. new GroupwareBundle($this->l10n),
  40. new SocialSharingBundle($this->l10n),
  41. new EducationBundle($this->l10n),
  42. ];
  43. }
  44. /**
  45. * Get the bundle with the specified identifier
  46. *
  47. * @param string $identifier
  48. * @return Bundle
  49. * @throws \BadMethodCallException If the bundle does not exist
  50. */
  51. public function getBundleByIdentifier(string $identifier): Bundle {
  52. foreach ($this->getBundles() as $bundle) {
  53. if ($bundle->getIdentifier() === $identifier) {
  54. return $bundle;
  55. }
  56. }
  57. throw new \BadMethodCallException('Bundle with specified identifier does not exist');
  58. }
  59. }