Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Director often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Director, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | /** |
||
| 25 | * Director is responsible for processing URLs, and providing environment information. |
||
| 26 | * |
||
| 27 | * The most important part of director is {@link Director::direct()}, which is passed a URL and will |
||
| 28 | * execute the appropriate controller. |
||
| 29 | * |
||
| 30 | * Director also has a number of static methods that provide information about the environment, such as |
||
| 31 | * {@link Director::$environment_type}. |
||
| 32 | * |
||
| 33 | * @package framework |
||
| 34 | * |
||
| 35 | * @subpackage control |
||
| 36 | * |
||
| 37 | * @see Director::direct() |
||
| 38 | * @see Director::$rules |
||
| 39 | * @see Director::$environment_type |
||
| 40 | */ |
||
| 41 | class Director implements TemplateGlobalProvider { |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Specifies this url is relative to the base. |
||
| 45 | * |
||
| 46 | * @var string |
||
| 47 | */ |
||
| 48 | const BASE = 'BASE'; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Specifies this url is relative to the site root. |
||
| 52 | * |
||
| 53 | * @var string |
||
| 54 | */ |
||
| 55 | const ROOT = 'ROOT'; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * specifies this url is relative to the current request. |
||
| 59 | * |
||
| 60 | * @var string |
||
| 61 | */ |
||
| 62 | const REQUEST = 'REQUEST'; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var array |
||
| 66 | */ |
||
| 67 | static private $urlParams; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @var array |
||
| 71 | */ |
||
| 72 | static private $rules = array(); |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @var SiteTree |
||
| 76 | */ |
||
| 77 | private static $current_page; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @config |
||
| 81 | * |
||
| 82 | * @var string |
||
| 83 | */ |
||
| 84 | private static $alternate_base_folder; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @config |
||
| 88 | * |
||
| 89 | * @var array |
||
| 90 | */ |
||
| 91 | private static $dev_servers = array(); |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @config |
||
| 95 | * |
||
| 96 | * @var array |
||
| 97 | */ |
||
| 98 | private static $test_servers = array(); |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Setting this explicitly specifies the protocol ("http" or "https") used, overriding the normal |
||
| 102 | * behaviour of Director::is_https introspecting it from the request. False values imply default |
||
| 103 | * introspection. |
||
| 104 | * |
||
| 105 | * @config |
||
| 106 | * |
||
| 107 | * @var string |
||
| 108 | */ |
||
| 109 | private static $alternate_protocol; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * @config |
||
| 113 | * |
||
| 114 | * @var string |
||
| 115 | */ |
||
| 116 | private static $alternate_base_url; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @config |
||
| 120 | * |
||
| 121 | * @var string |
||
| 122 | */ |
||
| 123 | private static $environment_type; |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Add URL matching rules to the Director. The director is responsible for turning URLs into |
||
| 127 | * Controller objects. |
||
| 128 | * |
||
| 129 | * Higher $priority values will get your rule checked first. We recommend priority 100 for your |
||
| 130 | * site's rules. The built-in rules are priority 10, standard modules are priority 50. |
||
| 131 | * |
||
| 132 | * @deprecated 4.0 Use the "Director.rules" config setting instead |
||
| 133 | * |
||
| 134 | * @param int $priority |
||
| 135 | * @param array $rules |
||
| 136 | */ |
||
| 137 | public static function addRules($priority, $rules) { |
||
| 142 | |||
| 143 | /** |
||
| 144 | * Process the given URL, creating the appropriate controller and executing it. |
||
| 145 | * |
||
| 146 | * Request processing is handled as follows: |
||
| 147 | * - Director::direct() creates a new SS_HTTPResponse object and passes this to |
||
| 148 | * Director::handleRequest(). |
||
| 149 | * - Director::handleRequest($request) checks each of the Director rules and identifies a controller |
||
| 150 | * to handle this request. |
||
| 151 | * - Controller::handleRequest($request) is then called. This will find a rule to handle the URL, |
||
| 152 | * and call the rule handling method. |
||
| 153 | * - RequestHandler::handleRequest($request) is recursively called whenever a rule handling method |
||
| 154 | * returns a RequestHandler object. |
||
| 155 | * |
||
| 156 | * In addition to request processing, Director will manage the session, and perform the output of |
||
| 157 | * the actual response to the browser. |
||
| 158 | * |
||
| 159 | * @uses handleRequest() rule-lookup logic is handled by this. |
||
| 160 | * @uses Controller::run() Controller::run() handles the page logic for a Director::direct() call. |
||
| 161 | * |
||
| 162 | * @param string $url |
||
| 163 | * @param DataModel $model |
||
| 164 | * |
||
| 165 | * @throws SS_HTTPResponse_Exception |
||
| 166 | */ |
||
| 167 | public static function direct($url, DataModel $model) { |
||
| 260 | |||
| 261 | /** |
||
| 262 | * Test a URL request, returning a response object. This method is the counterpart of |
||
| 263 | * Director::direct() that is used in functional testing. It will execute the URL given, and |
||
| 264 | * return the result as an SS_HTTPResponse object. |
||
| 265 | * |
||
| 266 | * @uses getControllerForURL() The rule-lookup logic is handled by this. |
||
| 267 | * @uses Controller::run() Handles the page logic for a Director::direct() call. |
||
| 268 | * |
||
| 269 | * @param string $url The URL to visit. |
||
| 270 | * @param array $postVars The $_POST & $_FILES variables. |
||
| 271 | * @param array|Session $session The {@link Session} object representing the current session. |
||
| 272 | * By passing the same object to multiple calls of Director::test(), you can simulate a persisted |
||
| 273 | * session. |
||
| 274 | * @param string $httpMethod The HTTP method, such as GET or POST. It will default to POST if |
||
| 275 | * postVars is set, GET otherwise. Overwritten by $postVars['_method'] if present. |
||
| 276 | * @param string $body The HTTP body. |
||
| 277 | * @param array $headers HTTP headers with key-value pairs. |
||
| 278 | * @param array|Cookie_Backend $cookies to populate $_COOKIE. |
||
| 279 | * @param HTTP_Request $request The {@see HTTP_Request} object generated as a part of this request. |
||
| 280 | * |
||
| 281 | * @return SS_HTTPResponse |
||
| 282 | * |
||
| 283 | * @throws SS_HTTPResponse_Exception |
||
| 284 | */ |
||
| 285 | public static function test($url, $postVars = null, $session = array(), $httpMethod = null, $body = null, |
||
| 413 | |||
| 414 | /** |
||
| 415 | * Handle an HTTP request, defined with a SS_HTTPRequest object. |
||
| 416 | * |
||
| 417 | * @param SS_HTTPRequest $request |
||
| 418 | * @param Session $session |
||
| 419 | * @param DataModel $model |
||
| 420 | * |
||
| 421 | * @return SS_HTTPResponse|string |
||
| 422 | */ |
||
| 423 | protected static function handleRequest(HTTPRequest $request, Session $session, DataModel $model) { |
||
| 475 | |||
| 476 | /** |
||
| 477 | * Set url parameters (should only be called internally by RequestHandler->handleRequest()). |
||
| 478 | * |
||
| 479 | * @param array $params |
||
| 480 | */ |
||
| 481 | public static function setUrlParams($params) { |
||
| 484 | |||
| 485 | /** |
||
| 486 | * Return the {@link SiteTree} object that is currently being viewed. If there is no SiteTree |
||
| 487 | * object to return, then this will return the current controller. |
||
| 488 | * |
||
| 489 | * @return SiteTree |
||
| 490 | */ |
||
| 491 | public static function get_current_page() { |
||
| 494 | |||
| 495 | /** |
||
| 496 | * Set the currently active {@link SiteTree} object that is being used to respond to the request. |
||
| 497 | * |
||
| 498 | * @param SiteTree $page |
||
| 499 | */ |
||
| 500 | public static function set_current_page($page) { |
||
| 503 | |||
| 504 | /** |
||
| 505 | * Turns the given URL into an absolute URL. By default non-site root relative urls will be |
||
| 506 | * evaluated relative to the current base_url. |
||
| 507 | * |
||
| 508 | * @param string $url URL To transform to absolute. |
||
| 509 | * @param string $relativeParent Method to use for evaluating relative urls. |
||
| 510 | * Either one of BASE (baseurl), ROOT (site root), or REQUEST (requested page). |
||
| 511 | * Defaults to BASE, which is the same behaviour as template url resolution. |
||
| 512 | * Ignored if the url is absolute or site root. |
||
| 513 | * |
||
| 514 | * @return string |
||
| 515 | */ |
||
| 516 | public static function absoluteURL($url, $relativeParent = self::BASE) { |
||
| 558 | |||
| 559 | /** |
||
| 560 | * Returns the domain part of the URL 'http://www.mysite.com'. Returns FALSE is this environment |
||
| 561 | * variable isn't set. |
||
| 562 | * |
||
| 563 | * @return bool|string |
||
| 564 | */ |
||
| 565 | public static function protocolAndHost() { |
||
| 593 | |||
| 594 | /** |
||
| 595 | * Return the current protocol that the site is running under. |
||
| 596 | * |
||
| 597 | * @return string |
||
| 598 | */ |
||
| 599 | public static function protocol() { |
||
| 602 | |||
| 603 | /** |
||
| 604 | * Return whether the site is running as under HTTPS. |
||
| 605 | * |
||
| 606 | * @return bool |
||
| 607 | */ |
||
| 608 | public static function is_https() { |
||
| 639 | |||
| 640 | /** |
||
| 641 | * Returns the root URL for the site. It will be automatically calculated unless it is overridden |
||
| 642 | * with {@link setBaseURL()}. |
||
| 643 | * |
||
| 644 | * @return string |
||
| 645 | */ |
||
| 646 | public static function baseURL() { |
||
| 667 | |||
| 668 | /** |
||
| 669 | * Sets the root URL for the website. If the site isn't accessible from the URL you provide, |
||
| 670 | * weird things will happen. |
||
| 671 | * |
||
| 672 | * @deprecated 4.0 Use the "Director.alternate_base_url" config setting instead. |
||
| 673 | * |
||
| 674 | * @param string $baseURL |
||
| 675 | */ |
||
| 676 | public static function setBaseURL($baseURL) { |
||
| 680 | |||
| 681 | /** |
||
| 682 | * Returns the root filesystem folder for the site. It will be automatically calculated unless |
||
| 683 | * it is overridden with {@link setBaseFolder()}. |
||
| 684 | * |
||
| 685 | * @return string |
||
| 686 | */ |
||
| 687 | public static function baseFolder() { |
||
| 691 | |||
| 692 | /** |
||
| 693 | * Sets the root folder for the website. If the site isn't accessible from the folder you provide, |
||
| 694 | * weird things will happen. |
||
| 695 | * |
||
| 696 | * @deprecated 4.0 Use the "Director.alternate_base_folder" config setting instead. |
||
| 697 | * |
||
| 698 | * @param string $baseFolder |
||
| 699 | */ |
||
| 700 | public static function setBaseFolder($baseFolder) { |
||
| 704 | |||
| 705 | /** |
||
| 706 | * Turns an absolute URL or folder into one that's relative to the root of the site. This is useful |
||
| 707 | * when turning a URL into a filesystem reference, or vice versa. |
||
| 708 | * |
||
| 709 | * @param string $url Accepts both a URL or a filesystem path. |
||
| 710 | * |
||
| 711 | * @return string |
||
| 712 | */ |
||
| 713 | public static function makeRelative($url) { |
||
| 758 | |||
| 759 | /** |
||
| 760 | * Returns true if a given path is absolute. Works under both *nix and windows systems. |
||
| 761 | * |
||
| 762 | * @param string $path |
||
| 763 | * |
||
| 764 | * @return bool |
||
| 765 | */ |
||
| 766 | public static function is_absolute($path) { |
||
| 771 | |||
| 772 | /** |
||
| 773 | * Determine if the url is root relative (i.e. starts with /, but not with //) SilverStripe |
||
| 774 | * considers root relative urls as a subset of relative urls. |
||
| 775 | * |
||
| 776 | * @param string $url |
||
| 777 | * |
||
| 778 | * @return bool |
||
| 779 | */ |
||
| 780 | public static function is_root_relative_url($url) { |
||
| 783 | |||
| 784 | /** |
||
| 785 | * Checks if a given URL is absolute (e.g. starts with 'http://' etc.). URLs beginning with "//" |
||
| 786 | * are treated as absolute, as browsers take this to mean the same protocol as currently being used. |
||
| 787 | * |
||
| 788 | * Useful to check before redirecting based on a URL from user submissions through $_GET or $_POST, |
||
| 789 | * and avoid phishing attacks by redirecting to an attackers server. |
||
| 790 | * |
||
| 791 | * Note: Can't solely rely on PHP's parse_url() , since it is not intended to work with relative URLs |
||
| 792 | * or for security purposes. filter_var($url, FILTER_VALIDATE_URL) has similar problems. |
||
| 793 | * |
||
| 794 | * @param string $url |
||
| 795 | * |
||
| 796 | * @return bool |
||
| 797 | */ |
||
| 798 | public static function is_absolute_url($url) { |
||
| 823 | |||
| 824 | /** |
||
| 825 | * Checks if a given URL is relative (or root relative) by checking {@link is_absolute_url()}. |
||
| 826 | * |
||
| 827 | * @param string $url |
||
| 828 | * |
||
| 829 | * @return bool |
||
| 830 | */ |
||
| 831 | public static function is_relative_url($url) { |
||
| 834 | |||
| 835 | /** |
||
| 836 | * Checks if the given URL is belonging to this "site" (not an external link). That's the case if |
||
| 837 | * the URL is relative, as defined by {@link is_relative_url()}, or if the host matches |
||
| 838 | * {@link protocolAndHost()}. |
||
| 839 | * |
||
| 840 | * Useful to check before redirecting based on a URL from user submissions through $_GET or $_POST, |
||
| 841 | * and avoid phishing attacks by redirecting to an attackers server. |
||
| 842 | * |
||
| 843 | * @param string $url |
||
| 844 | * |
||
| 845 | * @return bool |
||
| 846 | */ |
||
| 847 | public static function is_site_url($url) { |
||
| 856 | |||
| 857 | /** |
||
| 858 | * Takes a $_SERVER data array and extracts HTTP request headers. |
||
| 859 | * |
||
| 860 | * @param array $server |
||
| 861 | * |
||
| 862 | * @return array |
||
| 863 | */ |
||
| 864 | public static function extract_request_headers(array $server) { |
||
| 881 | |||
| 882 | /** |
||
| 883 | * Given a filesystem reference relative to the site root, return the full file-system path. |
||
| 884 | * |
||
| 885 | * @param string $file |
||
| 886 | * |
||
| 887 | * @return string |
||
| 888 | */ |
||
| 889 | public static function getAbsFile($file) { |
||
| 892 | |||
| 893 | /** |
||
| 894 | * Returns true if the given file exists. Filename should be relative to the site root. |
||
| 895 | * |
||
| 896 | * @param $file |
||
| 897 | * |
||
| 898 | * @return bool |
||
| 899 | */ |
||
| 900 | public static function fileExists($file) { |
||
| 905 | |||
| 906 | /** |
||
| 907 | * Returns the Absolute URL of the site root. |
||
| 908 | * |
||
| 909 | * @return string |
||
| 910 | */ |
||
| 911 | public static function absoluteBaseURL() { |
||
| 917 | |||
| 918 | /** |
||
| 919 | * Returns the Absolute URL of the site root, embedding the current basic-auth credentials into |
||
| 920 | * the URL. |
||
| 921 | * |
||
| 922 | * @return string |
||
| 923 | */ |
||
| 924 | public static function absoluteBaseURLWithAuth() { |
||
| 932 | |||
| 933 | /** |
||
| 934 | * Skip any further processing and immediately respond with a redirect to the passed URL. |
||
| 935 | * |
||
| 936 | * @param string $destURL |
||
| 937 | */ |
||
| 938 | protected static function force_redirect($destURL) { |
||
| 948 | |||
| 949 | /** |
||
| 950 | * Force the site to run on SSL. |
||
| 951 | * |
||
| 952 | * To use, call from _config.php. For example: |
||
| 953 | * <code> |
||
| 954 | * if (Director::isLive()) Director::forceSSL(); |
||
| 955 | * </code> |
||
| 956 | * |
||
| 957 | * If you don't want your entire site to be on SSL, you can pass an array of PCRE regular expression |
||
| 958 | * patterns for matching relative URLs. For example: |
||
| 959 | * <code> |
||
| 960 | * if (Director::isLive()) Director::forceSSL(array('/^admin/', '/^Security/')); |
||
| 961 | * </code> |
||
| 962 | * |
||
| 963 | * If you want certain parts of your site protected under a different domain, you can specify |
||
| 964 | * the domain as an argument: |
||
| 965 | * <code> |
||
| 966 | * if (Director::isLive()) Director::forceSSL(array('/^admin/', '/^Security/'), 'secure.mysite.com'); |
||
| 967 | * </code> |
||
| 968 | * |
||
| 969 | * Note that the session data will be lost when moving from HTTP to HTTPS. It is your responsibility |
||
| 970 | * to ensure that this won't cause usability problems. |
||
| 971 | * |
||
| 972 | * CAUTION: This does not respect the site environment mode. You should check this |
||
| 973 | * as per the above examples using Director::isLive() or Director::isTest() for example. |
||
| 974 | * |
||
| 975 | * @param array $patterns Array of regex patterns to match URLs that should be HTTPS. |
||
| 976 | * @param string $secureDomain Secure domain to redirect to. Defaults to the current domain. |
||
| 977 | * |
||
| 978 | * @return bool|string String of URL when unit tests running, boolean FALSE if patterns don't match request URI. |
||
| 979 | */ |
||
| 980 | public static function forceSSL($patterns = null, $secureDomain = null) { |
||
| 1024 | |||
| 1025 | /** |
||
| 1026 | * Force a redirect to a domain starting with "www." |
||
| 1027 | */ |
||
| 1028 | public static function forceWWW() { |
||
| 1036 | |||
| 1037 | /** |
||
| 1038 | * Checks if the current HTTP-Request is an "Ajax-Request" by checking for a custom header set by |
||
| 1039 | * jQuery or whether a manually set request-parameter 'ajax' is present. |
||
| 1040 | * |
||
| 1041 | * @return bool |
||
| 1042 | */ |
||
| 1043 | public static function is_ajax() { |
||
| 1053 | |||
| 1054 | /** |
||
| 1055 | * Returns true if this script is being run from the command line rather than the web server. |
||
| 1056 | * |
||
| 1057 | * @return bool |
||
| 1058 | */ |
||
| 1059 | public static function is_cli() { |
||
| 1062 | |||
| 1063 | /** |
||
| 1064 | * Set the environment type of the current site. |
||
| 1065 | * |
||
| 1066 | * Typically, a SilverStripe site have a number of environments: |
||
| 1067 | * - Development environments, such a copy on your local machine. |
||
| 1068 | * - Test sites, such as the one you show the client before going live. |
||
| 1069 | * - The live site itself. |
||
| 1070 | * |
||
| 1071 | * The behaviour of these environments often varies slightly. For example, development sites may |
||
| 1072 | * have errors dumped to the screen, and order confirmation emails might be sent to the developer |
||
| 1073 | * instead of the client. |
||
| 1074 | * |
||
| 1075 | * To help with this, SilverStripe supports the notion of an environment type. The environment |
||
| 1076 | * type can be dev, test, or live. |
||
| 1077 | * |
||
| 1078 | * You can set it explicitly with {@link Director::set_environment_type()}. Or you can use |
||
| 1079 | * {@link Director::$dev_servers} and {@link Director::$test_servers} to set it implicitly, based |
||
| 1080 | * on the value of $_SERVER['HTTP_HOST']. If the HTTP_HOST value is one of the servers listed, |
||
| 1081 | * then the environment type will be test or dev. Otherwise, the environment type will be live. |
||
| 1082 | * |
||
| 1083 | * Dev mode can also be forced by putting ?isDev=1 in your URL, which will ask you to log in and |
||
| 1084 | * then push the site into dev mode for the remainder of the session. Putting ?isDev=0 onto the URL |
||
| 1085 | * can turn it back. |
||
| 1086 | * |
||
| 1087 | * Test mode can also be forced by putting ?isTest=1 in your URL, which will ask you to log in and |
||
| 1088 | * then push the site into test mode for the remainder of the session. Putting ?isTest=0 onto the URL |
||
| 1089 | * can turn it back. |
||
| 1090 | * |
||
| 1091 | * Generally speaking, these methods will be called from your _config.php file. |
||
| 1092 | * |
||
| 1093 | * Once the environment type is set, it can be checked with {@link Director::isDev()}, |
||
| 1094 | * {@link Director::isTest()}, and {@link Director::isLive()}. |
||
| 1095 | * |
||
| 1096 | * @deprecated 4.0 Use the "Director.environment_type" config setting instead |
||
| 1097 | * |
||
| 1098 | * @param $et string |
||
| 1099 | */ |
||
| 1100 | public static function set_environment_type($et) { |
||
| 1109 | |||
| 1110 | /** |
||
| 1111 | * Can also be checked with {@link Director::isDev()}, {@link Director::isTest()}, and |
||
| 1112 | * {@link Director::isLive()}. |
||
| 1113 | * |
||
| 1114 | * @return bool|string |
||
| 1115 | */ |
||
| 1116 | public static function get_environment_type() { |
||
| 1127 | |||
| 1128 | /** |
||
| 1129 | * This function will return true if the site is in a live environment. For information about |
||
| 1130 | * environment types, see {@link Director::set_environment_type()}. |
||
| 1131 | * |
||
| 1132 | * @return bool |
||
| 1133 | */ |
||
| 1134 | public static function isLive() { |
||
| 1137 | |||
| 1138 | /** |
||
| 1139 | * This function will return true if the site is in a development environment. For information about |
||
| 1140 | * environment types, see {@link Director::set_environment_type()}. |
||
| 1141 | * |
||
| 1142 | * @return bool |
||
| 1143 | */ |
||
| 1144 | View Code Duplication | public static function isDev() { |
|
| 1159 | |||
| 1160 | /** |
||
| 1161 | * This function will return true if the site is in a test environment. For information about |
||
| 1162 | * environment types, see {@link Director::set_environment_type()}. |
||
| 1163 | * |
||
| 1164 | * @return bool |
||
| 1165 | */ |
||
| 1166 | View Code Duplication | public static function isTest() { |
|
| 1184 | |||
| 1185 | /** |
||
| 1186 | * Check or update any temporary environment specified in the session. |
||
| 1187 | * |
||
| 1188 | * @return null|string |
||
| 1189 | */ |
||
| 1190 | protected static function session_environment() { |
||
| 1191 | // Set session from querystring |
||
| 1192 | if (isset($_GET['isDev'])) { |
||
| 1193 | if (isset($_SESSION)) { |
||
| 1194 | unset($_SESSION['isTest']); // In case we are changing from test mode |
||
| 1195 | $_SESSION['isDev'] = $_GET['isDev']; |
||
| 1196 | } |
||
| 1197 | return 'dev'; |
||
| 1198 | } elseif (isset($_GET['isTest'])) { |
||
| 1199 | if (isset($_SESSION)) { |
||
| 1200 | unset($_SESSION['isDev']); // In case we are changing from dev mode |
||
| 1201 | $_SESSION['isTest'] = $_GET['isTest']; |
||
| 1202 | } |
||
| 1203 | return 'test'; |
||
| 1204 | } |
||
| 1205 | // Check session |
||
| 1206 | if (isset($_SESSION['isDev']) && $_SESSION['isDev']) { |
||
| 1207 | return 'dev'; |
||
| 1208 | } elseif (isset($_SESSION['isTest']) && $_SESSION['isTest']) { |
||
| 1209 | return 'test'; |
||
| 1210 | } else { |
||
| 1211 | return null; |
||
| 1231 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.