Pimcore\Tool::getHostname PHP Method

getHostname() public static method

public static getHostname ( ) : string
return string
    public static function getHostname()
    {
        if (isset($_SERVER["HTTP_X_FORWARDED_HOST"]) && !empty($_SERVER["HTTP_X_FORWARDED_HOST"])) {
            $hostParts = explode(",", $_SERVER["HTTP_X_FORWARDED_HOST"]);
            $hostname = trim(end($hostParts));
        } else {
            $hostname = $_SERVER["HTTP_HOST"];
        }
        // remove port if set
        if (strpos($hostname, ":") !== false) {
            $hostname = preg_replace("@:[0-9]+@", "", $hostname);
        }
        return $hostname;
    }

Usage Example

示例#1
0
 /**
  * @return mixed|null
  * @throws \Exception
  */
 public static function getConfiguration()
 {
     $config = null;
     $configFile = PIMCORE_CONFIGURATION_DIRECTORY . "/hybridauth.php";
     if (is_file($configFile)) {
         $config = (include $configFile);
         $config["base_url"] = "http://" . \Pimcore\Tool::getHostname() . "/hybridauth/endpoint";
     } else {
         throw new \Exception("HybridAuth configuration not found. Please place it into this file: {$configFile}");
     }
     return $config;
 }
All Usage Examples Of Pimcore\Tool::getHostname