1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Sake |
4
|
|
|
* |
5
|
|
|
* @link http://github.com/sandrokeil/CodeGenerator for the canonical source repository |
6
|
|
|
* @copyright Copyright (c) 2014 Sandro Keil |
7
|
|
|
* @license http://github.com/sandrokeil/CodeGenerator/blob/master/LICENSE.txt New BSD License |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Sake\CodeGenerator\Code\Metadata; |
11
|
|
|
|
12
|
|
|
use Zend\Stdlib\AbstractOptions; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Code generator meta data |
16
|
|
|
* |
17
|
|
|
* Contains table/entity/class definitions to generate several classes |
18
|
|
|
*/ |
19
|
|
|
class MetadataInfo extends AbstractOptions |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
protected $table = array(); |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var array |
28
|
|
|
*/ |
29
|
|
|
protected $columns = array(); |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var array |
33
|
|
|
*/ |
34
|
|
|
protected $foreignKeys = array(); |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected $name; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return mixed |
43
|
|
|
*/ |
44
|
|
|
public function getName() |
45
|
|
|
{ |
46
|
|
|
return $this->name; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param mixed $name |
51
|
|
|
*/ |
52
|
|
|
public function setName($name) |
53
|
|
|
{ |
54
|
|
|
$this->name = $name; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Returns foreign keys data |
59
|
|
|
* |
60
|
|
|
* @param string $key Key, if not provided, complete array will be returned |
61
|
|
|
* @return array |
62
|
|
|
*/ |
63
|
|
|
public function getForeignKeys($key = null) |
64
|
|
|
{ |
65
|
|
|
if (null !== $key) { |
66
|
|
|
return $this->foreignKeys[$key]; |
67
|
|
|
} |
68
|
|
|
return $this->foreignKeys; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param array $foreignKeys |
73
|
|
|
*/ |
74
|
|
|
public function setForeignKeys(array $foreignKeys) |
75
|
|
|
{ |
76
|
|
|
$this->foreignKeys = $foreignKeys; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Returns columns data |
81
|
|
|
* |
82
|
|
|
* @param string $key Key, if not provided, complete array will be returned |
83
|
|
|
* @return array |
84
|
|
|
*/ |
85
|
|
|
public function getColumns($key = null) |
86
|
|
|
{ |
87
|
|
|
if (null !== $key) { |
88
|
|
|
return $this->columns[$key]; |
89
|
|
|
} |
90
|
|
|
return $this->columns; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param array $columns |
95
|
|
|
*/ |
96
|
|
|
public function setColumns(array $columns) |
97
|
|
|
{ |
98
|
|
|
$this->columns = $columns; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Returns table data |
103
|
|
|
* |
104
|
|
|
* @param string $key Key, if not provided, complete array will be returned |
105
|
|
|
* @return array |
106
|
|
|
*/ |
107
|
|
|
public function getTable($key = null) |
108
|
|
|
{ |
109
|
|
|
if (null !== $key) { |
110
|
|
|
return $this->table[$key]; |
111
|
|
|
} |
112
|
|
|
return $this->table; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @param array $table |
117
|
|
|
*/ |
118
|
|
|
public function setTable(array $table) |
119
|
|
|
{ |
120
|
|
|
$this->table = $table; |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|