-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLudoDBCollectionConfigParser.php
More file actions
115 lines (106 loc) · 2.65 KB
/
LudoDBCollectionConfigParser.php
File metadata and controls
115 lines (106 loc) · 2.65 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/**
* Created by JetBrains PhpStorm.
* User: Alf Magne
* Date: 14.01.13
* @package LudoDB
* @author Alf Magne Kalleland <post@dhtmlgoodies.com>
*/
/**
* Config parser for LudoDBCollection
* @package LudoDB
*/
class LudoDBCollectionConfigParser extends LudoDBConfigParser
{
/**
* Internal reference to LudoDBCollection
* @var LudoDBCollection
*/
private $model = null;
/**
* Name of table name for the LudoDBCollection handled by the parser
* @var string
*/
private $tableName;
/**
* Return table name
* @return string
*/
public function getTableName()
{
if (!isset($this->tableName)) {
$model = $this->getModel();
if (isset($model)) $this->tableName = $model->configParser()->getTableName();
}
return $this->tableName ;
}
/**
* Return LudoDBCollection handled by the parser.
* @return LudoDBModel|null
*/
public function getModel()
{
if (isset($this->config['model'])) {
// TODO singleton.
$this->model = $this->getModelInstance();
$this->model->clearValues();
return $this->model;
}
return null;
}
/**
* Return LudoDBCollection instance
* @return LudoDBModel
*/
private function getModelInstance()
{
if(!class_exists($this->config['model'])){
throw new LudoDBException("Class ". $this->config['model']. " does not exists");
}
return new $this->config['model'];
}
/**
* Return group by config property.
* @return string|null
*/
public function getGroupBy(){
return $this->getProperty('groupBy');
}
/**
* Return primary key config property.
* @return string|null
*/
public function getPK(){
return $this->getProperty('pk');
}
/**
* Return foreign key config property.
* @return string|null
*/
public function getFK(){
return $this->getProperty('fk');
}
/**
* Return childKey config property.
* @return string|null
*/
public function getChildKey(){
return $this->getProperty('childKey');
}
/**
* Return merge config property.
* @return array|null
*/
public function getMerged(){
return $this->getProperty('merge');
}
/**
* Returns true when foreign key column should be hidden from returned rows, i.e.
* the hideForeignKeys config property.
* @return bool
*/
public function shouldHideForeignKeys(){
$val = $this->getProperty('hideForeignKeys');
return isset($val) && $val;
}
}