Skip to content

Instantly share code, notes, and snippets.

@schulle4u
Last active October 12, 2023 11:33
Show Gist options
  • Save schulle4u/b2902aa8a24649203cfb0dda4b6bb830 to your computer and use it in GitHub Desktop.
Save schulle4u/b2902aa8a24649203cfb0dda4b6bb830 to your computer and use it in GitHub Desktop.
#Datenstrom-Yellow Command extension to show extension settings
<?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