forked from OpenStackweb/openstack-org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlobalTemplateHelpers.php
More file actions
50 lines (48 loc) · 1.99 KB
/
Copy pathGlobalTemplateHelpers.php
File metadata and controls
50 lines (48 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Copyright 2019 Open Infrastructure Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
final class GlobalTemplateHelpers implements TemplateGlobalProvider
{
/**
* Called by SSViewer to get a list of global variables to expose to the template, the static method to call on
* this class to get the value for those variables, and the class to use for casting the returned value for use
* in a template
*
* If the method to call is not included for a particular template variable, a method named the same as the
* template variable will be called
*
* If the casting class is not specified for a particular template variable, ViewableData::$default_cast is used
*
* The first letter of the template variable is case-insensitive. However the method name is always case sensitive.
*
* @return array Returns an array of items. Each key => value pair is one of three forms:
* - template name (no key)
* - template name => method name
* - template name => array(), where the array can contain these key => value pairs
* - "method" => method name
* - "casting" => casting class to use (i.e., Varchar, HTMLText, etc)
*/
public static function get_template_global_variables()
{
return [
'GetEnv' => [
'method' => 'get_env',
'casting' => 'Text',
],
];
}
public static function get_env($name)
{
return constant($name);
}
}