IManager.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace OCP\Settings;
  24. /**
  25. * @since 9.1
  26. */
  27. interface IManager {
  28. /**
  29. * @since 9.1.0
  30. */
  31. const KEY_ADMIN_SETTINGS = 'admin';
  32. /**
  33. * @since 9.1.0
  34. */
  35. const KEY_ADMIN_SECTION = 'admin-section';
  36. /**
  37. * sets up settings according to data specified by an apps info.xml, within
  38. * the <settings> element.
  39. *
  40. * @param array $settings an associative array, allowed keys are as specified
  41. * by the KEY_ constant of this interface. The value
  42. * must always be a class name, implement either
  43. * IAdmin or ISection. I.e. only one section and admin
  44. * setting can be configured per app.
  45. * @since 9.1.0
  46. */
  47. public function setupSettings(array $settings);
  48. /**
  49. * attempts to remove an apps section and/or settings entry. A listener is
  50. * added centrally making sure that this method is called ones an app was
  51. * disabled.
  52. *
  53. * What this does not help with is when applications change their settings
  54. * or section classes during their life time. New entries will be added,
  55. * but inactive ones will still reside in the database.
  56. *
  57. * @param string $appId
  58. * @since 9.1.0
  59. */
  60. public function onAppDisabled($appId);
  61. /**
  62. * The method should check all registered classes whether they are still
  63. * instantiable and remove them, if not. This method is called by a
  64. * background job once, after one or more apps were updated.
  65. *
  66. * An app`s info.xml can change during an update and make it unknown whether
  67. * a registered class name was changed or not. An old one would just stay
  68. * registered. Another case is if an admin takes a radical approach and
  69. * simply removes an app from the app folder. These unregular checks will
  70. * take care of such situations.
  71. *
  72. * @since 9.1.0
  73. */
  74. public function checkForOrphanedClassNames();
  75. /**
  76. * returns a list of the admin sections
  77. *
  78. * @return array array of ISection[] where key is the priority
  79. * @since 9.1.0
  80. */
  81. public function getAdminSections();
  82. /**
  83. * returns a list of the admin settings
  84. *
  85. * @param string $section the section id for which to load the settings
  86. * @return array array of IAdmin[] where key is the priority
  87. * @since 9.1.0
  88. */
  89. public function getAdminSettings($section);
  90. }