1 | <?php |
||
17 | abstract class AbstractElement |
||
18 | { |
||
19 | /** |
||
20 | * Declaration flag used to create full table diff. |
||
21 | * |
||
22 | * @var bool |
||
23 | */ |
||
24 | protected $declared = false; |
||
25 | |||
26 | /** |
||
27 | * Element name. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $name = ''; |
||
32 | |||
33 | /** |
||
34 | * @invisible |
||
35 | * |
||
36 | * @var AbstractTable |
||
37 | */ |
||
38 | protected $table = null; |
||
39 | |||
40 | /** |
||
41 | * @param AbstractTable $table |
||
42 | * @param string $name |
||
43 | * @param mixed $schema Driver specific schema information. |
||
44 | */ |
||
45 | public function __construct(AbstractTable $table, $name, $schema = null) |
||
54 | |||
55 | /** |
||
56 | * Associated table. |
||
57 | * |
||
58 | * @return AbstractTable |
||
59 | */ |
||
60 | public function getTable() |
||
64 | |||
65 | /** |
||
66 | * Set element name. |
||
67 | * |
||
68 | * @param string $name |
||
69 | * |
||
70 | * @return $this |
||
71 | */ |
||
72 | public function setName($name) |
||
78 | |||
79 | /** |
||
80 | * Get element name. Can automatically quote such name. |
||
81 | * |
||
82 | * @param bool $quoted |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | public function getName($quoted = false) |
||
94 | |||
95 | /** |
||
96 | * @return bool |
||
97 | */ |
||
98 | public function isDeclared() |
||
102 | |||
103 | /** |
||
104 | * Mark schema entity as declared, it will be kept in final diff. |
||
105 | * |
||
106 | * @param bool $declared |
||
107 | * |
||
108 | * @return $this |
||
109 | */ |
||
110 | public function declared($declared = true) |
||
116 | |||
117 | /** |
||
118 | * Element creation/definition syntax. |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | abstract public function sqlStatement(); |
||
123 | |||
124 | /** |
||
125 | * @return string |
||
126 | */ |
||
127 | public function __toString() |
||
131 | |||
132 | /** |
||
133 | * Parse driver specific schema information and populate element data. |
||
134 | * |
||
135 | * @param mixed $schema |
||
136 | * |
||
137 | * @throws SchemaException |
||
138 | */ |
||
139 | abstract protected function resolveSchema($schema); |
||
140 | } |
||
141 |