Public Member Functions | |
__construct () | |
addObject (Mage_Core_Model_Abstract $object, $alias='') | |
save () | |
delete () | |
Protected Member Functions | |
_startTransaction () | |
_commitTransaction () | |
_rollbackTransaction () | |
Protected Attributes | |
$_objects = array() | |
$_objectsByAlias = array() | |
$_resources = array() |
Definition at line 36 of file Transaction.php.
__construct | ( | ) |
_commitTransaction | ( | ) | [protected] |
Enter description here...
Definition at line 87 of file Transaction.php.
00088 { 00089 foreach ($this->_objects as $object) { 00090 $object->getResource()->commit(); 00091 } 00092 return $this; 00093 }
_rollbackTransaction | ( | ) | [protected] |
Enter description here...
Definition at line 100 of file Transaction.php.
00101 { 00102 foreach ($this->_objects as $object) { 00103 $object->getResource()->rollBack(); 00104 } 00105 return $this; 00106 }
_startTransaction | ( | ) | [protected] |
Enter description here...
Definition at line 74 of file Transaction.php.
00075 { 00076 foreach ($this->_objects as $object) { 00077 $object->getResource()->beginTransaction(); 00078 } 00079 return $this; 00080 }
addObject | ( | Mage_Core_Model_Abstract $ | object, | |
$ | alias = '' | |||
) |
Adding object for using in transaction
Mage_Core_Model_Abstract | $object | |
string | $alias |
Definition at line 115 of file Transaction.php.
00116 { 00117 $this->_objects[] = $object; 00118 if (!empty($alias)) { 00119 $this->_objectsByAlias[$alias] = $object; 00120 } 00121 return $this; 00122 }
delete | ( | ) |
Initialize objects delete transaction
Definition at line 171 of file Transaction.php.
00172 { 00173 $this->_startTransaction(); 00174 try { 00175 foreach ($this->_objects as $object) { 00176 $object->delete(); 00177 } 00178 $this->_commitTransaction(); 00179 } 00180 catch (Exception $e) { 00181 $this->_rollbackTransaction(); 00182 throw $e; 00183 } 00184 return $this; 00185 }
save | ( | ) |
Initialize objects save transaction
Definition at line 129 of file Transaction.php.
00130 { 00131 $this->_startTransaction(); 00132 $commit = true; 00133 $errors = array(); 00134 00135 foreach ($this->_objects as $object) { 00136 try { 00137 $object->save(); 00138 } 00139 catch (Exception $e) { 00140 $commit = false; 00141 $errors[] = $e->getMessage(); 00142 } 00143 } 00144 00145 if ($commit) { 00146 $this->_commitTransaction(); 00147 } 00148 else { 00149 $this->_rollbackTransaction(); 00150 Mage::throwException(join("\n", $errors)); 00151 } 00152 00153 // try { 00154 // foreach ($this->_objects as $object) { 00155 // $object->save(); 00156 // } 00157 // $this->_commitTransaction(); 00158 // } 00159 // catch (Exception $e) { 00160 // $this->_rollbackTransaction(); 00161 // throw $e; 00162 // } 00163 return $this; 00164 }
$_objects = array() [protected] |
Definition at line 44 of file Transaction.php.
$_objectsByAlias = array() [protected] |
Definition at line 51 of file Transaction.php.
$_resources = array() [protected] |
Definition at line 58 of file Transaction.php.