-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclass.cb_template_handler.php
54 lines (45 loc) · 1.32 KB
/
class.cb_template_handler.php
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
51
52
53
54
<?php
class CbTemplateHandler implements CbResourceHandlerInterface {
protected $default_template; ///< Resource to be used if none is specified.
protected $templates;
/**
* Create a template provider.
* @param $config Global configuration.
*/
public function __construct($config)
{
$this->default_template = $config['default_template'];
$this->templates = $config['templates'];
}
private function resolveTemplate($request)
{
return isset($request['template']) ? $this->templates[$request['template']] : $this->default_template;
}
public function delete(array $params)
{
throw new CbApiException(403, 'You cannot modify templates.');
}
public function get(array $params)
{
return $this->resolveTemplate($params);
}
public function post(array $params)
{
throw new CbApiException(403, 'You cannot modify templates.');
}
public function put(array $params)
{
throw new CbApiException(403, 'You cannot modify templates.');
}
public function meta($request)
{
return array(
'last_modified' => filemtime($this->resolveTemplate($request)),
'privacy' => 'public',
'name' => $request['template'],
'formats' => array(
'text/html' => 'CbHtmlFileFormatter'
)
);
}
}