1 <?php
2 /**
3 * @package Joomla.Platform
4 * @subpackage Table
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 /**
13 * Table class supporting modified pre-order tree traversal behavior.
14 *
15 * @since 3.1.2
16 */
17 abstract class JTableObserver implements JObserverInterface
18 {
19 /**
20 * The observed table
21 *
22 * @var JTable
23 * @since 3.1.2
24 */
25 protected $table;
26
27 /**
28 * Constructor: Associates to $table $this observer
29 *
30 * @param JTableInterface $table Table to be observed
31 *
32 * @since 3.1.2
33 */
34 public function __construct(JTableInterface $table)
35 {
36 $table->attachObserver($this);
37 $this->table = $table;
38 }
39
40 /**
41 * Pre-processor for $table->load($keys, $reset)
42 *
43 * @param mixed $keys An optional primary key value to load the row by, or an array of fields to match. If not
44 * set the instance property value is used.
45 * @param boolean $reset True to reset the default values before loading the new row.
46 *
47 * @return void
48 *
49 * @since 3.1.2
50 */
51 public function onBeforeLoad($keys, $reset)
52 {
53 }
54
55 /**
56 * Post-processor for $table->load($keys, $reset)
57 *
58 * @param boolean &$result The result of the load
59 * @param array $row The loaded (and already binded to $this->table) row of the database table
60 *
61 * @return void
62 *
63 * @since 3.1.2
64 */
65 public function onAfterLoad(&$result, $row)
66 {
67 }
68
69 /**
70 * Pre-processor for $table->store($updateNulls)
71 *
72 * @param boolean $updateNulls The result of the load
73 * @param string $tableKey The key of the table
74 *
75 * @return void
76 *
77 * @since 3.1.2
78 */
79 public function onBeforeStore($updateNulls, $tableKey)
80 {
81 }
82
83 /**
84 * Post-processor for $table->store($updateNulls)
85 *
86 * @param boolean &$result The result of the store
87 *
88 * @return void
89 *
90 * @since 3.1.2
91 */
92 public function onAfterStore(&$result)
93 {
94 }
95
96 /**
97 * Pre-processor for $table->delete($pk)
98 *
99 * @param mixed $pk An optional primary key value to delete. If not set the instance property value is used.
100 *
101 * @return void
102 *
103 * @since 3.1.2
104 * @throws UnexpectedValueException
105 */
106 public function onBeforeDelete($pk)
107 {
108 }
109
110 /**
111 * Post-processor for $table->delete($pk)
112 *
113 * @param mixed $pk The deleted primary key value.
114 *
115 * @return void
116 *
117 * @since 3.1.2
118 */
119 public function onAfterDelete($pk)
120 {
121 }
122 }
123