// Empty for now
}
+ /**
+ * Compatiblity method to return this class' name
+ *
+ * @return __CLASS__ This class' name
+ */
+ public function __toString () {
+ return get_class($this);
+ }
+
/**
* Getter for an instance of this class
*
} // END - if
}
+ /**
+ * Checks wether the given configuration entry is set
+ *
+ * @param $configEntry The configuration entry we shall check
+ * @return $isset Wether the given configuration entry is set
+ */
+ protected function isConfigurationEntrySet ($configEntry) {
+ // Is it set?
+ $isset = isset($this->config[$configEntry]);
+
+ // Return the result
+ return $isset;
+ }
+
/**
* Read a configuration element.
*
if (empty($cfgEntry)) {
// Entry is empty
throw new ConfigEntryIsEmptyException($this, self::EXCEPTION_CONFIG_ENTRY_IS_EMPTY);
- } elseif (!isset($this->config[$cfgEntry])) {
+ } elseif (!$this->isConfigEntrySet($cfgEntry)) {
// Entry was not found!
throw new ConfigEntryNotFoundException(array(__CLASS__, $cfgEntry), self::EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND);
}
}
/**
- * Compatiblity method to return this class' name
+ * Detects the server address (SERVER_ADDR) and set it in configuration
*
- * @return __CLASS__ This class' name
+ * @return $serverAddress The detected server address
+ * @todo We have to add some more entries from $_SERVER here
*/
- public function __toString () {
- return get_class($this);
+ public function detectServerAddress () {
+ // Is the entry set?
+ if (!$this->isConfigurationEntrySet('server_addr')) {
+ // Is it set in $_SERVER?
+ if (isset($_SERVER['SERVER_ADDR'])) {
+ // Set it from $_SERVER
+ $this->setServerAddress($_SERVER['SERVER_ADDR']);
+ } elseif (class_exists('ConsoleTools')) {
+ // Run auto-detecting through console tools lib
+ ConsoleTools::acquireSelfIPAddress();
+ }
+ } // END - if
+
+ // Now get it from configuration
+ $serverAddress = $this->getServerAddress();
+
+ // Return it
+ return $serverAddress;
}
/**