1 | <?php |
||
19 | abstract class AbstractReference extends AbstractElement implements ReferenceInterface |
||
20 | { |
||
21 | /** |
||
22 | * Local column name (key name). |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $column = ''; |
||
27 | |||
28 | /** |
||
29 | * Referenced table name (including prefix). |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $foreignTable = ''; |
||
34 | |||
35 | /** |
||
36 | * Linked foreign key name (foreign column). |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $foreignKey = ''; |
||
41 | |||
42 | /** |
||
43 | * Action on foreign column value deletion. |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $deleteRule = self::NO_ACTION; |
||
48 | |||
49 | /** |
||
50 | * Action on foreign column value update. |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | protected $updateRule = self::NO_ACTION; |
||
55 | |||
56 | /** |
||
57 | * Mark schema entity as declared, it will be kept in final diff. |
||
58 | * |
||
59 | * @param bool $declared |
||
60 | * |
||
61 | * @return $this |
||
62 | */ |
||
63 | public function declared($declared = true) |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | * |
||
76 | * @param string $name |
||
77 | * |
||
78 | * @return $this |
||
79 | */ |
||
80 | public function setName($name) |
||
88 | |||
89 | /** |
||
90 | * {@inheritdoc} |
||
91 | * |
||
92 | * @param bool $quoted Quote name. |
||
93 | */ |
||
94 | public function getName($quoted = false) |
||
102 | |||
103 | /** |
||
104 | * {@inheritdoc} |
||
105 | */ |
||
106 | public function getColumn() |
||
110 | |||
111 | /** |
||
112 | * {@inheritdoc} |
||
113 | */ |
||
114 | public function getForeignTable() |
||
118 | |||
119 | /** |
||
120 | * {@inheritdoc} |
||
121 | */ |
||
122 | public function getForeignKey() |
||
126 | |||
127 | /** |
||
128 | * {@inheritdoc} |
||
129 | */ |
||
130 | public function getDeleteRule() |
||
134 | |||
135 | /** |
||
136 | * {@inheritdoc} |
||
137 | */ |
||
138 | public function getUpdateRule() |
||
142 | |||
143 | /** |
||
144 | * Set local column name foreign key relates to. Make sure column type is the same as foreign |
||
145 | * column one. |
||
146 | * |
||
147 | * @param string $column |
||
148 | * |
||
149 | * @return $this |
||
150 | */ |
||
151 | public function column($column) |
||
157 | |||
158 | /** |
||
159 | * Set foreign table name and key local column must reference to. Make sure local and foreign |
||
160 | * column types are identical. |
||
161 | * |
||
162 | * @param string $table Foreign table name without database prefix (will be added |
||
163 | * automatically). |
||
164 | * @param string $column Foreign key name (id by default). |
||
165 | * |
||
166 | * @return $this |
||
167 | */ |
||
168 | public function references($table, $column = 'id') |
||
175 | |||
176 | /** |
||
177 | * Set foreign key delete behaviour. |
||
178 | * |
||
179 | * @param string $rule Possible values: NO ACTION, CASCADE, etc (driver specific). |
||
180 | * |
||
181 | * @return $this |
||
182 | */ |
||
183 | public function onDelete($rule = self::NO_ACTION) |
||
189 | |||
190 | /** |
||
191 | * Set foreign key update behaviour. |
||
192 | * |
||
193 | * @param string $rule Possible values: NO ACTION, CASCADE, etc (driver specific). |
||
194 | * |
||
195 | * @return $this |
||
196 | */ |
||
197 | public function onUpdate($rule = self::NO_ACTION) |
||
203 | |||
204 | /** |
||
205 | * Foreign key creation syntax. |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | public function sqlStatement() |
||
226 | |||
227 | /** |
||
228 | * Compare two elements together. |
||
229 | * |
||
230 | * @param self $initial |
||
231 | * |
||
232 | * @return bool |
||
233 | */ |
||
234 | public function compare(self $initial) |
||
241 | |||
242 | /** |
||
243 | * Generate unique foreign key name. |
||
244 | * |
||
245 | * @return string |
||
246 | */ |
||
247 | protected function generateName() |
||
258 | } |
||
259 |