rename IAdmin to ISettings, the interface is not bound to a specific settings scope

This commit is contained in:
Arthur Schiwon 2016-08-11 14:48:21 +02:00
parent f3b15a9ab9
commit 14ddf9d923
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
11 changed files with 31 additions and 28 deletions

View File

@ -33,10 +33,10 @@ use OCP\ILogger;
use OCP\ISession; use OCP\ISession;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\IUserSession; use OCP\IUserSession;
use OCP\Settings\IAdmin; use OCP\Settings\ISettings;
use OCP\IConfig; use OCP\IConfig;
class Admin implements IAdmin { class Admin implements ISettings {
/** @var IL10N */ /** @var IL10N */
private $l; private $l;

View File

@ -34,9 +34,9 @@ use OCP\IDateTimeFormatter;
use OCP\IL10N; use OCP\IL10N;
use OCP\IRequest; use OCP\IRequest;
use OCP\Security\ISecureRandom; use OCP\Security\ISecureRandom;
use OCP\Settings\IAdmin; use OCP\Settings\ISettings;
class AdminController extends Controller implements IAdmin { class AdminController extends Controller implements ISettings {
/** @var IJobList */ /** @var IJobList */
private $jobList; private $jobList;
/** @var ISecureRandom */ /** @var ISecureRandom */

View File

@ -27,10 +27,10 @@ use OCA\User_LDAP\Configuration;
use OCA\User_LDAP\Helper; use OCA\User_LDAP\Helper;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N; use OCP\IL10N;
use OCP\Settings\IAdmin; use OCP\Settings\ISettings;
use OCP\Template; use OCP\Template;
class Admin implements IAdmin { class Admin implements ISettings {
/** @var IL10N */ /** @var IL10N */
private $l; private $l;

View File

@ -26,9 +26,9 @@ namespace OC\Settings\Admin;
use OC\Encryption\Manager; use OC\Encryption\Manager;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\Settings\IAdmin; use OCP\Settings\ISettings;
class Encryption implements IAdmin { class Encryption implements ISettings {
/** @var Manager */ /** @var Manager */
private $manager; private $manager;

View File

@ -26,9 +26,9 @@ namespace OC\Settings\Admin;
use OC\Log\File as LogFile; use OC\Log\File as LogFile;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig; use OCP\IConfig;
use OCP\Settings\IAdmin; use OCP\Settings\ISettings;
class Logging implements IAdmin { class Logging implements ISettings {
/** @var IConfig */ /** @var IConfig */
private $config; private $config;

View File

@ -29,9 +29,9 @@ use Doctrine\DBAL\Platforms\SqlitePlatform;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig; use OCP\IConfig;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\Settings\IAdmin; use OCP\Settings\ISettings;
class Server implements IAdmin { class Server implements ISettings {
/** @var IDBConnection|Connection */ /** @var IDBConnection|Connection */
private $db; private $db;

View File

@ -25,9 +25,9 @@ namespace OC\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig; use OCP\IConfig;
use OCP\Settings\IAdmin; use OCP\Settings\ISettings;
class Sharing implements IAdmin { class Sharing implements ISettings {
/** @var IConfig */ /** @var IConfig */
private $config; private $config;

View File

@ -25,9 +25,9 @@ namespace OC\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig; use OCP\IConfig;
use OCP\Settings\IAdmin; use OCP\Settings\ISettings;
class TipsTricks implements IAdmin { class TipsTricks implements ISettings {
/** @var IConfig */ /** @var IConfig */
private $config; private $config;

View File

@ -30,7 +30,7 @@ use OCP\IDBConnection;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\Settings\IAdmin; use OCP\Settings\ISettings;
use OCP\Settings\IManager; use OCP\Settings\IManager;
use OCP\Settings\ISection; use OCP\Settings\ISection;
@ -119,7 +119,7 @@ class Manager implements IManager {
]); ]);
} }
private function addAdminSettings(IAdmin $settings) { private function addAdminSettings(ISettings $settings) {
$this->add(self::TABLE_ADMIN_SETTINGS, [ $this->add(self::TABLE_ADMIN_SETTINGS, [
'class' => get_class($settings), 'class' => get_class($settings),
'section' => $settings->getSection(), 'section' => $settings->getSection(),
@ -136,7 +136,7 @@ class Manager implements IManager {
$query->execute(); $query->execute();
} }
private function updateAdminSettings(IAdmin $settings) { private function updateAdminSettings(ISettings $settings) {
$this->update( $this->update(
self::TABLE_ADMIN_SETTINGS, self::TABLE_ADMIN_SETTINGS,
'class', 'class',
@ -210,14 +210,14 @@ class Manager implements IManager {
} }
try { try {
/** @var IAdmin $settings */ /** @var ISettings $settings */
$settings = $this->query($settingsClassName); $settings = $this->query($settingsClassName);
} catch (QueryException $e) { } catch (QueryException $e) {
// cancel // cancel
return; return;
} }
if(!$settings instanceof IAdmin) { if(!$settings instanceof ISettings) {
$this->log->error( $this->log->error(
'Admin section instance must implement \OCP\ISection. Invalid class: {class}', 'Admin section instance must implement \OCP\ISection. Invalid class: {class}',
['class' => $settingsClassName] ['class' => $settingsClassName]
@ -283,27 +283,27 @@ class Manager implements IManager {
$forms = []; $forms = [];
try { try {
if($section === 'server') { if($section === 'server') {
/** @var IAdmin $form */ /** @var ISettings $form */
$form = new Admin\Server($this->dbc, $this->config); $form = new Admin\Server($this->dbc, $this->config);
$forms[$form->getPriority()] = [$form]; $forms[$form->getPriority()] = [$form];
} }
if($section === 'encryption') { if($section === 'encryption') {
/** @var IAdmin $form */ /** @var ISettings $form */
$form = new Admin\Encryption($this->encryptionManager, $this->userManager); $form = new Admin\Encryption($this->encryptionManager, $this->userManager);
$forms[$form->getPriority()] = [$form]; $forms[$form->getPriority()] = [$form];
} }
if($section === 'sharing') { if($section === 'sharing') {
/** @var IAdmin $form */ /** @var ISettings $form */
$form = new Admin\Sharing($this->config); $form = new Admin\Sharing($this->config);
$forms[$form->getPriority()] = [$form]; $forms[$form->getPriority()] = [$form];
} }
if($section === 'logging') { if($section === 'logging') {
/** @var IAdmin $form */ /** @var ISettings $form */
$form = new Admin\Logging($this->config); $form = new Admin\Logging($this->config);
$forms[$form->getPriority()] = [$form]; $forms[$form->getPriority()] = [$form];
} }
if($section === 'tips-tricks') { if($section === 'tips-tricks') {
/** @var IAdmin $form */ /** @var ISettings $form */
$form = new Admin\TipsTricks($this->config); $form = new Admin\TipsTricks($this->config);
$forms[$form->getPriority()] = [$form]; $forms[$form->getPriority()] = [$form];
} }

View File

@ -25,15 +25,17 @@ namespace OCP\Settings;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
interface IAdmin { interface ISettings {
/** /**
* @return TemplateResponse returns the instance with all parameters set, ready to be rendered * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
* @since 9.1
*/ */
public function getForm(); public function getForm();
/** /**
* @return string the section ID, e.g. 'sharing' * @return string the section ID, e.g. 'sharing'
* @since 9.1
*/ */
public function getSection(); public function getSection();
@ -43,6 +45,7 @@ interface IAdmin {
* priority values. It is required to return a value between 0 and 100. * priority values. It is required to return a value between 0 and 100.
* *
* E.g.: 70 * E.g.: 70
* @since 9.1
*/ */
public function getPriority(); public function getPriority();
} }

View File

@ -91,7 +91,7 @@ class AdminSettingsController extends Controller {
$html = ''; $html = '';
foreach ($settings as $prioritizedSettings) { foreach ($settings as $prioritizedSettings) {
foreach ($prioritizedSettings as $setting) { foreach ($prioritizedSettings as $setting) {
/** @var \OCP\Settings\IAdmin $setting */ /** @var \OCP\Settings\ISettings $setting */
$form = $setting->getForm(); $form = $setting->getForm();
$html .= $form->renderAs('')->render(); $html .= $form->renderAs('')->render();
} }