Remove ISection in favor of IIconSection

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2020-10-28 22:51:49 +01:00
parent ef382f541c
commit b8ed997238
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
8 changed files with 43 additions and 87 deletions

View File

@ -34,7 +34,6 @@ use OCP\IGroupManager;
use OCP\INavigationManager;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Settings\IIconSection;
use OCP\Settings\IManager as ISettingsManager;
use OCP\Settings\ISettings;
@ -84,7 +83,7 @@ trait CommonSettingsTrait {
protected function formatSections($sections, $currentSection, $type, $currentType, bool $subAdminOnly = false) {
$templateParameters = [];
/** @var \OCP\Settings\ISection[] $prioritizedSections */
/** @var \OCP\Settings\IIconSection[] $prioritizedSections */
foreach ($sections as $prioritizedSections) {
foreach ($prioritizedSections as $section) {
if ($type === 'admin') {
@ -96,10 +95,7 @@ trait CommonSettingsTrait {
continue;
}
$icon = '';
if ($section instanceof IIconSection) {
$icon = $section->getIcon();
}
$icon = $section->getIcon();
$active = $section->getID() === $currentSection
&& $type === $currentType;

View File

@ -35,7 +35,7 @@ use OCP\Search\IProvider;
use OCP\Search\ISearchQuery;
use OCP\Search\SearchResult;
use OCP\Search\SearchResultEntry;
use OCP\Settings\ISection;
use OCP\Settings\IIconSection;
use OCP\Settings\IManager;
class SectionSearch implements IProvider {
@ -117,7 +117,7 @@ class SectionSearch implements IProvider {
/**
* @param ISearchQuery $query
* @param ISection[][] $sections
* @param IIconSection[][] $sections
* @param string $subline
* @param string $routeName
* @return array
@ -135,10 +135,7 @@ class SectionSearch implements IProvider {
/**
* We can't use the icon URL at the moment as they don't invert correctly for dark theme
* $iconUrl = '';
* if ($section instanceof IIconSection) {
* $iconUrl = $section->getIcon();
* }
*/
$result[] = new SearchResultEntry(

View File

@ -34,7 +34,7 @@ use OCA\Theming\Util;
use OCP\AppFramework\App;
use OCP\Capabilities\ICapability;
use OCP\IL10N;
use OCP\Settings\ISection;
use OCP\Settings\IIconSection;
use OCP\Settings\ISettings;
use Test\TestCase;
@ -75,7 +75,7 @@ class ServicesTest extends TestCase {
[Admin::class],
[Admin::class, ISettings::class],
[Section::class],
[Section::class, ISection::class],
[Section::class, IIconSection::class],
];
}

View File

@ -463,7 +463,6 @@ return array(
'OCP\\Session\\Exceptions\\SessionNotAvailableException' => $baseDir . '/lib/public/Session/Exceptions/SessionNotAvailableException.php',
'OCP\\Settings\\IIconSection' => $baseDir . '/lib/public/Settings/IIconSection.php',
'OCP\\Settings\\IManager' => $baseDir . '/lib/public/Settings/IManager.php',
'OCP\\Settings\\ISection' => $baseDir . '/lib/public/Settings/ISection.php',
'OCP\\Settings\\ISettings' => $baseDir . '/lib/public/Settings/ISettings.php',
'OCP\\Settings\\ISubAdminSettings' => $baseDir . '/lib/public/Settings/ISubAdminSettings.php',
'OCP\\Share' => $baseDir . '/lib/public/Share.php',

View File

@ -492,7 +492,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\Session\\Exceptions\\SessionNotAvailableException' => __DIR__ . '/../../..' . '/lib/public/Session/Exceptions/SessionNotAvailableException.php',
'OCP\\Settings\\IIconSection' => __DIR__ . '/../../..' . '/lib/public/Settings/IIconSection.php',
'OCP\\Settings\\IManager' => __DIR__ . '/../../..' . '/lib/public/Settings/IManager.php',
'OCP\\Settings\\ISection' => __DIR__ . '/../../..' . '/lib/public/Settings/ISection.php',
'OCP\\Settings\\ISettings' => __DIR__ . '/../../..' . '/lib/public/Settings/ISettings.php',
'OCP\\Settings\\ISubAdminSettings' => __DIR__ . '/../../..' . '/lib/public/Settings/ISubAdminSettings.php',
'OCP\\Share' => __DIR__ . '/../../..' . '/lib/public/Share.php',

View File

@ -38,8 +38,8 @@ use OCP\ILogger;
use OCP\IServerContainer;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use OCP\Settings\IIconSection;
use OCP\Settings\IManager;
use OCP\Settings\ISection;
use OCP\Settings\ISettings;
use OCP\Settings\ISubAdminSettings;
@ -80,7 +80,7 @@ class Manager implements IManager {
/**
* @param string $type 'admin' or 'personal'
* @param string $section Class must implement OCP\Settings\ISection
* @param string $section Class must implement OCP\Settings\IIconSection
*
* @return void
*/
@ -95,7 +95,7 @@ class Manager implements IManager {
/**
* @param string $type 'admin' or 'personal'
*
* @return ISection[]
* @return IIconSection[]
*/
protected function getSections(string $type): array {
if (!isset($this->sections[$type])) {
@ -108,18 +108,13 @@ class Manager implements IManager {
foreach (array_unique($this->sectionClasses[$type]) as $index => $class) {
try {
/** @var ISection $section */
/** @var IIconSection $section */
$section = \OC::$server->query($class);
} catch (QueryException $e) {
$this->log->logException($e, ['level' => ILogger::INFO]);
continue;
}
if (!$section instanceof ISection) {
$this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => ILogger::INFO]);
continue;
}
$sectionID = $section->getID();
if ($sectionID !== 'connected-accounts' && isset($this->sections[$type][$sectionID])) {
@ -212,7 +207,7 @@ class Manager implements IManager {
$appSections = $this->getSections('admin');
foreach ($appSections as $section) {
/** @var ISection $section */
/** @var IIconSection $section */
if (!isset($sections[$section->getPriority()])) {
$sections[$section->getPriority()] = [];
}
@ -269,7 +264,7 @@ class Manager implements IManager {
$appSections = $this->getSections('personal');
foreach ($appSections as $section) {
/** @var ISection $section */
/** @var IIconSection $section */
if (!isset($sections[$section->getPriority()])) {
$sections[$section->getPriority()] = [];
}

View File

@ -2,7 +2,9 @@
/**
* @copyright Copyright (c) 2017, Joas Schilling <coding@schilljs.com>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @license GNU AGPL version 3 or any later version
*
@ -26,7 +28,35 @@ namespace OCP\Settings;
/**
* @since 12
*/
interface IIconSection extends ISection {
interface IIconSection {
/**
* returns the ID of the section. It is supposed to be a lower case string,
* e.g. 'ldap'
*
* @returns string
* @since 9.1
*/
public function getID();
/**
* returns the translated name as it should be displayed, e.g. 'LDAP / AD
* integration'. Use the L10N service to translate it.
*
* @return string
* @since 9.1
*/
public function getName();
/**
* @return int whether the form should be rather on the top or bottom of
* the settings navigation. The sections are arranged in ascending order of
* the priority values. It is required to return a value between 0 and 99.
*
* E.g.: 70
* @since 9.1
*/
public function getPriority();
/**
* returns the relative path to an 16*16 icon describing the section.
* e.g. '/core/img/places/files.svg'

View File

@ -1,60 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Settings;
/**
* @deprecated 12 Use IIconSection instead
* @since 9.1
*/
interface ISection {
/**
* returns the ID of the section. It is supposed to be a lower case string,
* e.g. 'ldap'
*
* @returns string
* @since 9.1
*/
public function getID();
/**
* returns the translated name as it should be displayed, e.g. 'LDAP / AD
* integration'. Use the L10N service to translate it.
*
* @return string
* @since 9.1
*/
public function getName();
/**
* @return int whether the form should be rather on the top or bottom of
* the settings navigation. The sections are arranged in ascending order of
* the priority values. It is required to return a value between 0 and 99.
*
* E.g.: 70
* @since 9.1
*/
public function getPriority();
}