Overview

Namespaces

  • Mapbender
    • Component
      • HTTP
    • CoreBundle
      • Command
      • Component
        • Exception
      • Controller
      • DataFixtures
        • ORM
      • DependencyInjection
      • Element
        • Type
      • Entity
      • EventListener
      • Extension
      • Form
        • DataTransformer
        • EventListener
        • Type
      • Security
      • Template
    • KmlBundle
      • Element
    • ManagerBundle
      • Controller
      • Form
        • DataTransformer
        • Type
    • MonitoringBundle
      • Command
      • Component
      • Controller
      • DependencyInjection
      • Entity
      • EventListener
      • Form
    • PrintBundle
      • Component
      • Controller
    • WmcBundle
      • Component
        • Exception
      • Element
        • Type
      • Entity
      • Form
        • Type
    • WmsBundle
      • Component
        • Exception
      • Controller
      • DependencyInjection
      • Element
        • Type
      • Entity
      • Event
      • Form
        • EventListener
        • Type
    • WmtsBundle
      • Component
        • Exception
      • Controller
      • Entity
      • Form
        • Type
  • None
  • PHP

Classes

  • Application
  • ApplicationYAMLMapper
  • BoundingBox
  • Element
  • InstanceConfiguration
  • InstanceConfigurationOptions
  • MapbenderBundle
  • ProxyService
  • SQLSearchEngine
  • StateHandler
  • Template
  • Utils

Interfaces

  • InstanceLayerIn
  • SearchEngine
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
 1: <?php
 2: 
 3: namespace Mapbender\CoreBundle\Component;
 4: 
 5: /**
 6:  * The class with utility functions.
 7:  *
 8:  * @author Paul Schmidt
 9:  */
10: class Utils
11: {
12: 
13:     /**
14:      * Checks the variable $booleanOrNull and returns the boolean or null.
15:      * @param type $booleanOrNull
16:      * @param type $nullable
17:      * @return boolean if $nullable is false, otherwise boolean or null.
18:      */
19:     public static function getBool($booleanOrNull, $nullable = false)
20:     {
21:         if($nullable)
22:         {
23:             return $booleanOrNull;
24:         } else
25:         {
26:             return $booleanOrNull === null ? false : $booleanOrNull;
27:         }
28:     }
29: 
30:     /**
31:      * Generats an URL from base url and GET parameters
32:      * 
33:      * @param string $baseUrl A base URL
34:      * @param string $parameters GET Parameters as array or as string
35:      * @return generated Url
36:      */
37:     public static function getHttpUrl($baseUrl, $parameters)
38:     {
39:         $url = "";
40:         $pos = strpos($baseUrl, "?");
41:         if($pos === false)
42:         {
43:             $url = $baseUrl . "?";
44:         } else if(strlen($baseUrl) - 1 !== $pos)
45:         {
46:             $pos = strpos($baseUrl, "&");
47:             if($pos === false)
48:             {
49:                 $url = $baseUrl . "&";
50:             } else if(strlen($baseUrl) - 1 !== $pos)
51:             {
52:                 $url = $baseUrl . "&";
53:             } else
54:             {
55:                 $url = $baseUrl;
56:             }
57:         } else
58:         {
59:             $url = $baseUrl;
60:         }
61:         if(is_string($parameters))
62:         {
63:             return $url . $parameters;
64:         } else if(is_array($parameters))
65:         {
66:             $params = array();
67:             foreach($parameters as $key => $value)
68:             {
69:                 if(is_string($key))
70:                 {
71:                     $params[] = $key . "=" . $value;
72:                 } else
73:                 {
74:                     $params[] = $value;
75:                 }
76:             }
77:             return $url . implode("&", $params);
78:         }
79:         return null;
80:     }
81: 
82: }
83: 
Mapbender3 API documenation API documentation generated by ApiGen 2.8.0