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