1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Fwk |
4
|
|
|
* |
5
|
|
|
* Copyright (c) 2011-2014, Julien Ballestracci <[email protected]>. |
6
|
|
|
* All rights reserved. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
12
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
13
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
14
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
15
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
16
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
17
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
18
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
19
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
20
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
21
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
22
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
23
|
|
|
* |
24
|
|
|
* PHP Version 5.3 |
25
|
|
|
* |
26
|
|
|
* @category Database |
27
|
|
|
* @package Fwk |
28
|
|
|
* @subpackage Db |
29
|
|
|
* @author Julien Ballestracci <[email protected]> |
30
|
|
|
* @copyright 2011-2014 Julien Ballestracci <[email protected]> |
31
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
32
|
|
|
* @link http://www.nitronet.org/fwk |
33
|
|
|
*/ |
34
|
|
|
namespace Fwk\Db\Events; |
35
|
|
|
|
36
|
|
|
use Fwk\Events\Event; |
37
|
|
|
use Fwk\Db\Connection; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Fired when the state of the connection changes |
41
|
|
|
* |
42
|
|
|
* @category Events |
43
|
|
|
* @package Fwk\Db |
44
|
|
|
* @author Julien Ballestracci <[email protected]> |
45
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
46
|
|
|
* @link http://www.nitronet.org/fwk |
47
|
|
|
*/ |
48
|
|
|
class ConnectionStateChangeEvent extends Event |
49
|
|
|
{ |
50
|
|
|
const EVENT_NAME = 'connectionStateChange'; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Constructor |
54
|
|
|
* |
55
|
|
|
* @param Connection $connection The DB connection |
56
|
|
|
* @param integer $previousState Previous state of the connection |
57
|
|
|
* @param integer $newState New state |
58
|
|
|
* |
59
|
|
|
* @return void |
|
|
|
|
60
|
|
|
*/ |
61
|
|
|
public function __construct(Connection $connection, $previousState, $newState) |
62
|
|
|
{ |
63
|
|
|
parent::__construct( |
64
|
|
|
self::EVENT_NAME, array( |
65
|
|
|
'connection' => $connection, |
66
|
|
|
'previousState' => (int)$previousState, |
67
|
|
|
'newState' => (int)$newState |
68
|
|
|
) |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Returns the Connection instance |
74
|
|
|
* |
75
|
|
|
* @return Connection |
76
|
|
|
*/ |
77
|
|
|
public function getConnection() |
78
|
|
|
{ |
79
|
|
|
return $this->connection; |
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Returns the previous state of the connection |
84
|
|
|
* |
85
|
|
|
* @return integer |
86
|
|
|
*/ |
87
|
|
|
public function getPreviousState() |
88
|
|
|
{ |
89
|
|
|
return $this->previousState; |
|
|
|
|
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Returns the new state of the connection |
94
|
|
|
* |
95
|
|
|
* @return integer |
96
|
|
|
*/ |
97
|
|
|
public function getNewState() |
98
|
|
|
{ |
99
|
|
|
return $this->newState; |
|
|
|
|
100
|
|
|
} |
101
|
|
|
} |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.