Completed
Push — master ( 5f0535...74f4b9 )
by Jean-Christophe
01:50
created

CRUDDatas   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 3
dl 0
loc 73
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getTableNames() 0 3 1
A getFieldNames() 0 3 1
A getFormFieldNames() 0 3 1
A getSearchFieldNames() 0 3 1
A getElementFieldNames() 0 3 1
A getManyToManyDatas() 0 3 1
A getUpdateOneToManyInForm() 0 3 1
A getUpdateManyToManyInForm() 0 3 1
A getUpdateManyToOneInForm() 0 3 1
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
	public function getFieldNames($model){
25
		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
	 */
32
	public function getFormFieldNames($model){
33
		return OrmUtils::getSerializableFields($model);
34
	}
35
	
36
	/**
37
	 * Returns the fields to use in search queries
38
	 * @param string $model
39
	 */
40
	public function getSearchFieldNames($model){
41
		return OrmUtils::getSerializableFields($model);
42
	}
43
	
44
	/**
45
	 * Returns the fields for displaying an instance of $model (DataElement)
46
	 * @param string $model
47
	 */
48
	public function getElementFieldNames($model){
49
		return OrmUtils::getMembers($model);
50
	}
51
52
	/**
53
	 * Returns a list of $fkClass objects to select a value for $member
54
	 * @param string $fkClass
55
	 * @param object $instance
56
	 * @param string $member
57
	 * @return array
58
	 */
59
	public function getManyToManyDatas($fkClass,$instance,$member){
60
		return DAO::getAll($fkClass);
61
	}
62
63
	/**
64
	 * @return boolean
65
	 */
66
	public function getUpdateOneToManyInForm() {
67
		return false;
68
	}
69
70
	/**
71
	 * @return boolean
72
	 */
73
	public function getUpdateManyToManyInForm() {
74
		return true;
75
	}
76
77
	/**
78
	 * @return boolean
79
	 */
80
	public function getUpdateManyToOneInForm() {
81
		return true;
82
	}
83
}
84