-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dispatch.php
69 lines (62 loc) · 1.36 KB
/
Dispatch.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* @version 1.0
* @author Paul Dragoonis <dragoonis@php.net>
* @license http://opensource.org/licenses/mit-license.php MIT
* @copyright Digiflex Development
* @package Dispatch
* @link www.ppiframework.com
*/
class PPI_Dispatch {
/**
* The actual helper doing the dispatching
*
* @var object that implements PPI_Dispatch_Interface
*/
protected $_helper = null;
protected $_render404 = false;
/**
* The router doing the routing
*
* @var PPI_Router
*/
protected $_router = null;
/**
* Identify and store the appropriate Controller and Methods to dispatch at a later time when calling dispatch()
*
*/
function __construct(PPI_Dispatch_Interface $p_oDispatch) {
$this->_helper = $p_oDispatch;
if($this->_helper->init() === false) {
$this->_render404 = true;
}
}
/**
* Call the dispatch process for the current set helper
*
* @return void
*/
function dispatch() {
if($this->_render404) {
PPI_Exception::show_404('Invalid dispatch process');
return;
}
$this->_helper->dispatch();
}
/**
* Get the currently chosen controller name
*
* @return string
*/
function getControllerName() {
return $this->_helper->getControllerName();
}
/**
* Get the current set method name on the chosen class.
*
* @return string
*/
function getMethodName() {
return $this->_helper->getMethod();
}
}