-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): implement config lexicon
Signed-off-by: Maxence Lange <[email protected]>
- Loading branch information
1 parent
7bd9100
commit e49c1a5
Showing
9 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* @copyright Copyright (c) 2024 Maxence Lange <[email protected]> | ||
* | ||
* @author Maxence Lange <[email protected]> | ||
* | ||
* @license AGPL-3.0 or later | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* 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, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
namespace OC\ConfigLexicon; | ||
|
||
use OC; | ||
use OCP\ConfigLexicon\IConfigLexiconEntry; | ||
|
||
class ConfigLexiconEntry implements IConfigLexiconEntry { | ||
private string $definition = ''; | ||
private ?string $default = null; | ||
private bool $lazy = false; | ||
private bool $sensitive = false; | ||
private bool $deprecated = false; | ||
|
||
public function __construct( | ||
private string $key, | ||
private int $valueType, | ||
string $definition = '', | ||
) { | ||
|
||
if (OC::$CLI) { // only store definition if ran from CLI | ||
$this->definition = $definition; | ||
} | ||
} | ||
|
||
public function getKey(): string { | ||
return $this->key; | ||
} | ||
|
||
public function getValueType(): int { | ||
return $this->valueType; | ||
} | ||
|
||
public function withDefaultString(string $default): self { | ||
$this->default = $default; | ||
return $this; | ||
} | ||
|
||
public function withDefaultInt(int $default): self { | ||
$this->default = (string) $default; | ||
return $this; | ||
} | ||
|
||
public function withDefaultFloat(float $default): self { | ||
$this->default = (string) $default; | ||
return $this; | ||
} | ||
|
||
public function withDefaultBool(bool $default): self { | ||
$this->default = ($default) ? '1' : '0'; | ||
return $this; | ||
} | ||
|
||
public function withDefaultArray(array $default): self { | ||
$this->default = json_encode($default); | ||
return $this; | ||
} | ||
|
||
public function getDefault(): ?string { | ||
return $this->default; | ||
} | ||
|
||
public function getDefinition(): string { | ||
return $this->definition; | ||
} | ||
|
||
public function asLazy(bool $lazy = true): self { | ||
$this->lazy = $lazy; | ||
return $this; | ||
} | ||
|
||
public function isLazy(): bool { | ||
return $this->lazy; | ||
} | ||
|
||
public function asSensitive(bool $sensitive = true): self { | ||
$this->sensitive = $sensitive; | ||
return $this; | ||
} | ||
|
||
public function isSensitive(): bool { | ||
return $this->sensitive; | ||
} | ||
|
||
public function asDeprecated(bool $deprecated = true): self { | ||
$this->deprecated = $deprecated; | ||
return $this; | ||
} | ||
|
||
public function isDeprecated(): bool { | ||
return $this->deprecated; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace OCP\ConfigLexicon; | ||
|
||
interface IConfigLexicon { | ||
Check failure on line 5 in lib/public/ConfigLexicon/IConfigLexicon.php GitHub Actions / static-code-analysis-ocpInvalidDocblock
|
||
public function isStrict(): bool; | ||
|
||
/** | ||
* @return IConfigLexiconEntry[] | ||
*/ | ||
public function getAppConfigs(): array; | ||
Check failure on line 11 in lib/public/ConfigLexicon/IConfigLexicon.php GitHub Actions / static-code-analysis-ocpInvalidDocblock
|
||
/** | ||
* @return IConfigLexiconEntry[] | ||
*/ | ||
public function getUserPreferences(): array; | ||
Check failure on line 15 in lib/public/ConfigLexicon/IConfigLexicon.php GitHub Actions / static-code-analysis-ocpInvalidDocblock
|
||
} |
Oops, something went wrong.