Passed
Push — master ( e1ca0a...c1379c )
by Jean-Christophe
04:54
created

CRUDDatas::getUpdateManyToManyInForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Ubiquity\controllers\crud;
3
use Ubiquity\orm\DAO;
4
use Ubiquity\orm\OrmUtils;
5
6
/**
7
 * The base class for displaying datas in CRUD controllers
8
 * @author jc
9
 *
10
 */
11
class CRUDDatas {
12
13
	/**
14
	 * Returns the table names to display in the left admin menu
15
	 */
16
	public function getTableNames(){
17
		return DAO::$db->getTablesName();
18
	}
19
20
	/**
21
	 * Returns the fields to display in the showModel action for $model (DataTable)
22
	 * @param string $model
23
	 */
24 5
	public function getFieldNames($model){
25 5
		return OrmUtils::getSerializableFields($model);
26
	}
27
28
	/**
29
	 * Returns the fields to update in the edit an new action for $model
30
	 * @param string $model
31
	 * @param object $instance
32
	 */
33 3
	public function getFormFieldNames($model,$instance){
34 3
		return OrmUtils::getFormAllFields($model);
35
	}
36
	
37
	/**
38
	 * Returns the fields to use in search queries
39
	 * @param string $model
40
	 */
41 1
	public function getSearchFieldNames($model){
42 1
		return OrmUtils::getSerializableFields($model);
43
	}
44
	
45
	/**
46
	 * Returns the fields for displaying an instance of $model (DataElement)
47
	 * @param string $model
48
	 */
49 1
	public function getElementFieldNames($model){
50 1
		return OrmUtils::getMembers($model);
51
	}
52
53
	/**
54
	 * Returns a (filtered) list of $fkClass objects to display in an html list
55
	 * @param string $fkClass
56
	 * @param object $instance
57
	 * @param string $member The member associated with a manyToMany relation
58
	 * @return array
59
	 */
60
	public function getManyToManyDatas($fkClass,$instance,$member){
61
		return DAO::getAll($fkClass,"",false);
62
	}
63
	
64
	/**
65
	 * Returns a list (filtered) of $fkClass objects to display in an html list
66
	 * @param string $fkClass
67
	 * @param object $instance
68
	 * @param string $member The member associated with a manyToOne relation
69
	 * @return array
70
	 */
71 1
	public function getManyToOneDatas($fkClass,$instance,$member){
72 1
		return DAO::getAll($fkClass,"",false);
73
	}
74
	
75
	/**
76
	 * Returns a list (filtered) of $fkClass objects to display in an html list
77
	 * @param string $fkClass
78
	 * @param object $instance
79
	 * @param string $member The member associated with a oneToMany relation
80
	 * @return array
81
	 */
82
	public function getOneToManyDatas($fkClass,$instance,$member){
83
		return DAO::getAll($fkClass,"",false);
84
	}
85
86
	/**
87
	 * @return boolean
88
	 */
89
	public function getUpdateOneToManyInForm() {
90
		return false;
91
	}
92
93
	/**
94
	 * @return boolean
95
	 */
96
	public function getUpdateManyToManyInForm() {
97
		return true;
98
	}
99
100
	/**
101
	 * @return boolean
102
	 */
103
	public function getUpdateManyToOneInForm() {
104
		return true;
105
	}
106
	
107
	/**
108
	 * Defines whether the refresh is partial or complete after an instance update
109
	 * @return boolean
110
	 */
111 2
	public function refreshPartialInstance(){
112 2
		return true;
113
	}
114
	
115
	/**
116
	 * Adds a condition for filtering the instances displayed in dataTable
117
	 * Return 1=1 by default
118
	 * @param string $model
119
	 * @return string
120
	 */
121 5
	public function _getInstancesFilter($model){
122 5
		return "1=1";
123
	}
124
}
125