diff --git a/_common/KeymanSiteEnvironment.php b/_common/KeymanSiteEnvironment.php new file mode 100644 index 0000000..5b2d9d6 --- /dev/null +++ b/_common/KeymanSiteEnvironment.php @@ -0,0 +1,82 @@ + $value) { + if (isset($env[$key])) { + echo "key $key, env[key] $env[$key]\n"; + self::__set($key, $env[$key]); + } + } + var_dump($this); + echo "__get: " . self::__get('LOGNAME') . "\n"; + } + + public function &__get($name) { return $this->data[$name]; } + public function __isset($name) { return isset($this->data[$name]); } + public function __set($name, $value) { $this->data[$name] = $value; } + public function __unset($name) { unset($this->data[$name]); } + + public static function Debug($class) { + $props = get_class_vars($class); + echo "------- Debug -------\n"; + var_dump($props); + echo "---------------------\n"; + } + } + + class HelpSiteEnvironment extends KeymanSiteEnvironment { + public ?string + // Expected env vars for help.keyman.com + $HOSTNAME = null, // Do not commit this line + $KEYMANHOSTS_TIER = null, + $LOGNAME = null, + $KEYMAN_COM_PROXY_PORT = null; + + const MY_KEYMAN = null; + + public function __construct() { + return new KeymanSiteEnvironment(get_class()); + } + + public static function Init() { + KeymanSiteEnvironment::Instance(get_class()); + + // For troubleshooting + KeymanSiteEnvironment::Instance()->Debug(get_class()); + } + } + + // Code for testing + HelpSiteEnvironment::Init(); + if (HelpSiteEnvironment::Instance()->__isset('LOGNAME')) { + echo "true\n"; + } else { + echo "false\n"; + } + \ No newline at end of file diff --git a/bootstrap.inc.sh b/bootstrap.inc.sh index 5bfaf14..7af8a02 100644 --- a/bootstrap.inc.sh +++ b/bootstrap.inc.sh @@ -100,6 +100,7 @@ function _bootstrap_configure_common() { JsonApiFailure.php KeymanHosts.php KeymanSentry.php + KeymanSiteEnvironment.php MarkdownHost.php ) local common_file=