Passed
Push — master ( 9c1274...95a447 )
by Jean-Christophe
06:00
created

RestController::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Ubiquity\controllers\rest;
4
5
use Ubiquity\cache\CacheManager;
6
use Ubiquity\orm\DAO;
7
8
/**
9
 * Abstract base class for Rest controllers
10
 * Ubiquity\controllers\rest$RestController
11
 * This class is part of Ubiquity
12
 *
13
 * @author jcheron <[email protected]>
14
 * @version 1.0.3
15
 *
16
 */
17
abstract class RestController extends RestBaseController {
18
19 1
	public function initialize() {
20 1
		$thisClass = \get_class ( $this );
21 1
		if (! isset ( $this->model ))
22 1
			$this->model = CacheManager::getRestResource ( $thisClass );
23 1
		if (! isset ( $this->model )) {
24
			$modelsNS = $this->config ["mvcNS"] ["models"];
25
			$this->model = $modelsNS . "\\" . $this->_getResponseFormatter ()->getModel ( $thisClass );
26
		}
27 1
		parent::initialize();
28 1
	}
29
30
	/**
31
	 * Returns all objects for the resource $model
32
	 */
33
	public function _index() {
34
		$datas = DAO::getAll ( $this->model );
35
		echo $this->_getResponseFormatter ()->get ( $datas );
36
	}
37
38
	/**
39
	 * Returns a list of objects from the server
40
	 *
41
	 * @param string $condition
42
	 *        	the sql Where part
43
	 * @param boolean|string $included
44
	 *        	if true, loads associate members with associations, if string, example : client.*,commands
45
	 * @param boolean $useCache
46
	 */
47 1
	public function get($condition = "1=1", $included = false, $useCache = false) {
48 1
		$this->_get($condition,$included,$useCache);
49 1
	}
50
51
	/**
52
	 * Get the first object corresponding to the $keyValues
53
	 *
54
	 * @param string $keyValues
55
	 *        	primary key(s) value(s) or condition
56
	 * @param boolean|string $included
57
	 *        	if true, loads associate members with associations, if string, example : client.*,commands
58
	 * @param boolean $useCache
59
	 *        	if true then response is cached
60
	 */
61 1
	public function getOne($keyValues, $included = false, $useCache = false) {
62 1
		$this->_getOne($keyValues,$included,$useCache);
63 1
	}
64
}
65