Manager.php
4.48 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php
namespace Phalcon\Mvc\Model\Transaction {
/**
* Phalcon\Mvc\Model\Transaction\Manager
*
* A transaction acts on a single database connection. If you have multiple class-specific
* databases, the transaction will not protect interaction among them.
*
* This class manages the objects that compose a transaction.
* A trasaction produces a unique connection that is passed to every
* object part of the transaction.
*
*<code>
*try {
*
* use Phalcon\Mvc\Model\Transaction\Manager as TransactionManager;
*
* $transactionManager = new TransactionManager();
*
* $transaction = $transactionManager->get();
*
* $robot = new Robots();
* $robot->setTransaction($transaction);
* $robot->name = 'WALL·E';
* $robot->created_at = date('Y-m-d');
* if($robot->save()==false){
* $transaction->rollback("Can't save robot");
* }
*
* $robotPart = new RobotParts();
* $robotPart->setTransaction($transaction);
* $robotPart->type = 'head';
* if($robotPart->save()==false){
* $transaction->rollback("Can't save robot part");
* }
*
* $transaction->commit();
*
*}
*catch(Phalcon\Mvc\Model\Transaction\Failed $e){
* echo 'Failed, reason: ', $e->getMessage();
*}
*
*</code>
*
*/
class Manager implements \Phalcon\Mvc\Model\Transaction\ManagerInterface, \Phalcon\DI\InjectionAwareInterface {
protected $_dependencyInjector;
protected $_initialized;
protected $_rollbackPendent;
protected $_number;
protected $_service;
protected $_transactions;
/**
* \Phalcon\Mvc\Model\Transaction\Manager constructor
*
* @param \Phalcon\DiInterface $dependencyInjector
*/
public function __construct($dependencyInjector=null){ }
/**
* Sets the dependency injection container
*
* @param \Phalcon\DiInterface $dependencyInjector
*/
public function setDI($dependencyInjector){ }
/**
* Returns the dependency injection container
*
* @return \Phalcon\DiInterface
*/
public function getDI(){ }
/**
* Sets the database service used to run the isolated transactions
*
* @param string $service
* @return \Phalcon\Mvc\Model\Transaction\Manager
*/
public function setDbService($service){ }
/**
* Returns the database service used to isolate the transaction
*
* @return string
*/
public function getDbService(){ }
/**
* Set if the transaction manager must register a shutdown function to clean up pendent transactions
*
* @param boolean $rollbackPendent
* @return \Phalcon\Mvc\Model\Transaction\Manager
*/
public function setRollbackPendent($rollbackPendent){ }
/**
* Check if the transaction manager is registering a shutdown function to clean up pendent transactions
*
* @return boolean
*/
public function getRollbackPendent(){ }
/**
* Checks whether the manager has an active transaction
*
* @return boolean
*/
public function has(){ }
/**
* Returns a new \Phalcon\Mvc\Model\Transaction or an already created once
* This method registers a shutdown function to rollback active connections
*
* @param boolean $autoBegin
* @return \Phalcon\Mvc\Model\TransactionInterface
*/
public function get($autoBegin=null){ }
/**
* Create/Returns a new transaction or an existing one
*
* @param boolean $autoBegin
* @return \Phalcon\Mvc\Model\TransactionInterface
*/
public function getOrCreateTransaction($autoBegin=null){ }
/**
* Rollbacks active transactions within the manager
*
*/
public function rollbackPendent(){ }
/**
* Commmits active transactions within the manager
*
*/
public function commit(){ }
/**
* Rollbacks active transactions within the manager
* Collect will remove transaction from the manager
*
* @param boolean $collect
*/
public function rollback($collect=null){ }
/**
* Notifies the manager about a rollbacked transaction
*
* @param \Phalcon\Mvc\Model\TransactionInterface $transaction
*/
public function notifyRollback($transaction){ }
/**
* Notifies the manager about a commited transaction
*
* @param \Phalcon\Mvc\Model\TransactionInterface $transaction
*/
public function notifyCommit($transaction){ }
/**
* Removes transactions from the TransactionManager
*
* @param \Phalcon\Mvc\Model\TransactionInterface $transaction
*/
protected function _collectTransaction(){ }
/**
* Remove all the transactions from the manager
*
*/
public function collectTransactions(){ }
}
}