-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseController.php
38 lines (35 loc) · 1.14 KB
/
BaseController.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
<?php
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'Controller.php');
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'UnknownActionException.php');
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'EmptyView.php');
/**
* The BaseController class implements the basic functionality of a Controller,
* but only returns an EmptyView. It serves mainly as an example of one way to
* implement a Controller, and as future-proofing in case shared functionality
* that should apply to all Controllers is determined in the future.
*
* @author Josh Endries <[email protected]>
* @since 2.0.0
*/
abstract class BaseController implements Controller {
public function service($name, Array $parameters) {
/*
* Create an EmptyView to return as a last resort.
*/
$view = new EmptyView();
/*
* Pass handling along to the correct method based on the action name.
*/
switch ($name) {
default:
/*
* We have no action by that name, so throw the appropriate exception.
*/
throw new UnknownActionException($name, __CLASS__.' cannot handle actions with name '.$name);
}
/*
* Return the view.
*/
return $view;
}
}