factory.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * @author Björn Schießle <schiessle@owncloud.com>
  4. *
  5. * @copyright Copyright (c) 2015, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace OC\Encryption\Keys;
  22. use OC\Encryption\Util;
  23. use OC\Files\View;
  24. use OC\User;
  25. /**
  26. * Factory provides KeyStorage for different encryption modules
  27. */
  28. class Factory {
  29. /** @var array */
  30. protected $instances = array();
  31. /**
  32. * get a KeyStorage instance
  33. *
  34. * @param string $encryptionModuleId
  35. * @param View $view
  36. * @param Util $util
  37. * @return Storage
  38. */
  39. public function get($encryptionModuleId,View $view, Util $util) {
  40. if (!isset($this->instances[$encryptionModuleId])) {
  41. $this->instances[$encryptionModuleId] = new Storage($encryptionModuleId, $view, $util);
  42. }
  43. return $this->instances[$encryptionModuleId];
  44. }
  45. }