1 <?php
2 /**
3 * @package FrameworkOnFramework
4 * @subpackage table
5 * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
6 * @license GNU General Public License version 2 or later; see LICENSE.txt
7 */
8 // Protect from unauthorized access
9 defined('FOF_INCLUDED') or die;
10
11 /**
12 * FrameworkOnFramework table behavior class. It defines the events which are
13 * called by a Table.
14 *
15 * @codeCoverageIgnore
16 * @package FrameworkOnFramework
17 * @since 2.1
18 */
19 abstract class FOFTableBehavior extends FOFUtilsObservableEvent
20 {
21 /**
22 * This event runs before binding data to the table
23 *
24 * @param FOFTable &$table The table which calls this event
25 * @param array &$data The data to bind
26 *
27 * @return boolean True on success
28 */
29 public function onBeforeBind(&$table, &$data)
30 {
31 return true;
32 }
33
34 /**
35 * The event which runs after binding data to the table
36 *
37 * @param FOFTable &$table The table which calls this event
38 * @param object|array &$src The data to bind
39 *
40 * @return boolean True on success
41 */
42 public function onAfterBind(&$table, &$src)
43 {
44 return true;
45 }
46
47 /**
48 * The event which runs after loading a record from the database
49 *
50 * @param FOFTable &$table The table which calls this event
51 * @param boolean &$result Did the load succeeded?
52 *
53 * @return void
54 */
55 public function onAfterLoad(&$table, &$result)
56 {
57
58 }
59
60 /**
61 * The event which runs before storing (saving) data to the database
62 *
63 * @param FOFTable &$table The table which calls this event
64 * @param boolean $updateNulls Should nulls be saved as nulls (true) or just skipped over (false)?
65 *
66 * @return boolean True to allow saving
67 */
68 public function onBeforeStore(&$table, $updateNulls)
69 {
70 return true;
71 }
72
73 /**
74 * The event which runs after storing (saving) data to the database
75 *
76 * @param FOFTable &$table The table which calls this event
77 *
78 * @return boolean True to allow saving without an error
79 */
80 public function onAfterStore(&$table)
81 {
82 return true;
83 }
84
85 /**
86 * The event which runs before moving a record
87 *
88 * @param FOFTable &$table The table which calls this event
89 * @param boolean $updateNulls Should nulls be saved as nulls (true) or just skipped over (false)?
90 *
91 * @return boolean True to allow moving
92 */
93 public function onBeforeMove(&$table, $updateNulls)
94 {
95 return true;
96 }
97
98 /**
99 * The event which runs after moving a record
100 *
101 * @param FOFTable &$table The table which calls this event
102 *
103 * @return boolean True to allow moving without an error
104 */
105 public function onAfterMove(&$table)
106 {
107 return true;
108 }
109
110 /**
111 * The event which runs before reordering a table
112 *
113 * @param FOFTable &$table The table which calls this event
114 * @param string $where The WHERE clause of the SQL query to run on reordering (record filter)
115 *
116 * @return boolean True to allow reordering
117 */
118 public function onBeforeReorder(&$table, $where = '')
119 {
120 return true;
121 }
122
123 /**
124 * The event which runs after reordering a table
125 *
126 * @param FOFTable &$table The table which calls this event
127 *
128 * @return boolean True to allow the reordering to complete without an error
129 */
130 public function onAfterReorder(&$table)
131 {
132 return true;
133 }
134
135 /**
136 * The event which runs before deleting a record
137 *
138 * @param FOFTable &$table The table which calls this event
139 * @param integer $oid The PK value of the record to delete
140 *
141 * @return boolean True to allow the deletion
142 */
143 public function onBeforeDelete(&$table, $oid)
144 {
145 return true;
146 }
147
148 /**
149 * The event which runs after deleting a record
150 *
151 * @param FOFTable &$table The table which calls this event
152 * @param integer $oid The PK value of the record which was deleted
153 *
154 * @return boolean True to allow the deletion without errors
155 */
156 public function onAfterDelete(&$table, $oid)
157 {
158 return true;
159 }
160
161 /**
162 * The event which runs before hitting a record
163 *
164 * @param FOFTable &$table The table which calls this event
165 * @param integer $oid The PK value of the record to hit
166 * @param boolean $log Should we log the hit?
167 *
168 * @return boolean True to allow the hit
169 */
170 public function onBeforeHit(&$table, $oid, $log)
171 {
172 return true;
173 }
174
175 /**
176 * The event which runs after hitting a record
177 *
178 * @param FOFTable &$table The table which calls this event
179 * @param integer $oid The PK value of the record which was hit
180 *
181 * @return boolean True to allow the hitting without errors
182 */
183 public function onAfterHit(&$table, $oid)
184 {
185 return true;
186 }
187
188 /**
189 * The even which runs before copying a record
190 *
191 * @param FOFTable &$table The table which calls this event
192 * @param integer $oid The PK value of the record being copied
193 *
194 * @return boolean True to allow the copy to take place
195 */
196 public function onBeforeCopy(&$table, $oid)
197 {
198 return true;
199 }
200
201 /**
202 * The even which runs after copying a record
203 *
204 * @param FOFTable &$table The table which calls this event
205 * @param integer $oid The PK value of the record which was copied (not the new one)
206 *
207 * @return boolean True to allow the copy without errors
208 */
209 public function onAfterCopy(&$table, $oid)
210 {
211 return true;
212 }
213
214 /**
215 * The event which runs before a record is (un)published
216 *
217 * @param FOFTable &$table The table which calls this event
218 * @param integer|array &$cid The PK IDs of the records being (un)published
219 * @param integer $publish 1 to publish, 0 to unpublish
220 *
221 * @return boolean True to allow the (un)publish to proceed
222 */
223 public function onBeforePublish(&$table, &$cid, $publish)
224 {
225 return true;
226 }
227
228 /**
229 * The event which runs after the object is reset to its default values.
230 *
231 * @param FOFTable &$table The table which calls this event
232 *
233 * @return boolean True to allow the reset to complete without errors
234 */
235 public function onAfterReset(&$table)
236 {
237 return true;
238 }
239
240 /**
241 * The even which runs before the object is reset to its default values.
242 *
243 * @param FOFTable &$table The table which calls this event
244 *
245 * @return boolean True to allow the reset to complete
246 */
247 public function onBeforeReset(&$table)
248 {
249 return true;
250 }
251 }
252