Last active
October 12, 2023 11:33
-
-
Save schulle4u/b2902aa8a24649203cfb0dda4b6bb830 to your computer and use it in GitHub Desktop.
#Datenstrom-Yellow Command extension to show extension settings
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
<?php | |
// Settings extension | |
class YellowSettings { | |
const VERSION = "0.1.3"; | |
public $yellow; // access to API | |
// Handle initialisation | |
public function onLoad($yellow) { | |
$this->yellow = $yellow; | |
} | |
// Handle command | |
public function onCommand($command, $text) { | |
$statusCode = 0; | |
if ($command=="settings") { | |
foreach ($this->yellow->system->getSettings($text) as $key=>$value) { | |
$defaultValue = isset($this->yellow->system->settingsDefaults[$key]) ? $this->yellow->system->settingsDefaults[$key] : "empty"; | |
echo "$key: $value (default: $defaultValue)\n"; | |
} | |
$statusCode = 200; | |
} | |
return $statusCode; | |
} | |
// Handle command help | |
public function onCommandHelp() { | |
return "settings [extension]\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment