-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcontroller.php
More file actions
executable file
·41 lines (33 loc) · 1.22 KB
/
controller.php
File metadata and controls
executable file
·41 lines (33 loc) · 1.22 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
<?php
/*
Paragon
Copyright (c) 2013 Brandon Goldman
Released under the MIT License.
*/
class Controller {
private $_slug;
public function __construct() {
$controller = get_class($this);
$controller_underscore = Paraglide::inflect_underscore($controller);
if (substr($controller_underscore, -strlen('_controller')) == '_controller') {
$controller_underscore = substr($controller_underscore, 0, -strlen('_controller'));
}
$this->_slug = Paraglide::$nested_dir;
if ($controller_underscore != DEFAULT_CONTROLLER) {
// we don't want to append the main controller's name to the url
$this->_slug .= $controller_underscore;
} else {
// remove the trailing /
$this->_slug = substr($this->_slug, 0, -1);
}
}
public function redirect($action = null, $params = null, $query_string = null, $ssl = false) {
return Paraglide::redirect($this->_slug, $action, $params, $query_string, $ssl);
}
public function render($view, $data = array(), $buffer = false) {
return Paraglide::render($this->_slug . '/' . $view, $data, $buffer);
}
public function url($action = null, $params = null, $query_string = null, $ssl = false) {
return Paraglide::url($this->_slug, $action, $params, $query_string, $ssl);
}
}