PageRenderTime 47ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/test/bin/model/om/BaseFakeForumI18n.php

https://bitbucket.org/anycode/sfluceneplugin
PHP | 502 lines | 340 code | 162 blank | 0 comment | 49 complexity | 39edea4c8a8dd9e95fb6f1e89d103bc0 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. abstract class BaseFakeForumI18n extends BaseObject implements Persistent {
  3. protected static $peer;
  4. protected $title;
  5. protected $description;
  6. protected $id;
  7. protected $culture;
  8. protected $aFakeForum;
  9. protected $alreadyInSave = false;
  10. protected $alreadyInValidation = false;
  11. public function getTitle()
  12. {
  13. return $this->title;
  14. }
  15. public function getDescription()
  16. {
  17. return $this->description;
  18. }
  19. public function getId()
  20. {
  21. return $this->id;
  22. }
  23. public function getCulture()
  24. {
  25. return $this->culture;
  26. }
  27. public function setTitle($v)
  28. {
  29. if ($v !== null && !is_string($v)) {
  30. $v = (string) $v;
  31. }
  32. if ($this->title !== $v) {
  33. $this->title = $v;
  34. $this->modifiedColumns[] = FakeForumI18nPeer::TITLE;
  35. }
  36. }
  37. public function setDescription($v)
  38. {
  39. if ($v !== null && !is_string($v)) {
  40. $v = (string) $v;
  41. }
  42. if ($this->description !== $v) {
  43. $this->description = $v;
  44. $this->modifiedColumns[] = FakeForumI18nPeer::DESCRIPTION;
  45. }
  46. }
  47. public function setId($v)
  48. {
  49. if ($v !== null && !is_int($v) && is_numeric($v)) {
  50. $v = (int) $v;
  51. }
  52. if ($this->id !== $v) {
  53. $this->id = $v;
  54. $this->modifiedColumns[] = FakeForumI18nPeer::ID;
  55. }
  56. if ($this->aFakeForum !== null && $this->aFakeForum->getId() !== $v) {
  57. $this->aFakeForum = null;
  58. }
  59. }
  60. public function setCulture($v)
  61. {
  62. if ($v !== null && !is_string($v)) {
  63. $v = (string) $v;
  64. }
  65. if ($this->culture !== $v) {
  66. $this->culture = $v;
  67. $this->modifiedColumns[] = FakeForumI18nPeer::CULTURE;
  68. }
  69. }
  70. public function hydrate(ResultSet $rs, $startcol = 1)
  71. {
  72. try {
  73. $this->title = $rs->getString($startcol + 0);
  74. $this->description = $rs->getString($startcol + 1);
  75. $this->id = $rs->getInt($startcol + 2);
  76. $this->culture = $rs->getString($startcol + 3);
  77. $this->resetModified();
  78. $this->setNew(false);
  79. return $startcol + 4;
  80. } catch (Exception $e) {
  81. throw new PropelException("Error populating FakeForumI18n object", $e);
  82. }
  83. }
  84. public function delete($con = null)
  85. {
  86. foreach (sfMixer::getCallables('BaseFakeForumI18n:delete:pre') as $callable)
  87. {
  88. $ret = call_user_func($callable, $this, $con);
  89. if ($ret)
  90. {
  91. return;
  92. }
  93. }
  94. if ($this->isDeleted()) {
  95. throw new PropelException("This object has already been deleted.");
  96. }
  97. if ($con === null) {
  98. $con = Propel::getConnection(FakeForumI18nPeer::DATABASE_NAME);
  99. }
  100. try {
  101. $con->begin();
  102. FakeForumI18nPeer::doDelete($this, $con);
  103. $this->setDeleted(true);
  104. $con->commit();
  105. } catch (PropelException $e) {
  106. $con->rollback();
  107. throw $e;
  108. }
  109. foreach (sfMixer::getCallables('BaseFakeForumI18n:delete:post') as $callable)
  110. {
  111. call_user_func($callable, $this, $con);
  112. }
  113. }
  114. public function save($con = null)
  115. {
  116. foreach (sfMixer::getCallables('BaseFakeForumI18n:save:pre') as $callable)
  117. {
  118. $affectedRows = call_user_func($callable, $this, $con);
  119. if (is_int($affectedRows))
  120. {
  121. return $affectedRows;
  122. }
  123. }
  124. if ($this->isDeleted()) {
  125. throw new PropelException("You cannot save an object that has been deleted.");
  126. }
  127. if ($con === null) {
  128. $con = Propel::getConnection(FakeForumI18nPeer::DATABASE_NAME);
  129. }
  130. try {
  131. $con->begin();
  132. $affectedRows = $this->doSave($con);
  133. $con->commit();
  134. foreach (sfMixer::getCallables('BaseFakeForumI18n:save:post') as $callable)
  135. {
  136. call_user_func($callable, $this, $con, $affectedRows);
  137. }
  138. return $affectedRows;
  139. } catch (PropelException $e) {
  140. $con->rollback();
  141. throw $e;
  142. }
  143. }
  144. protected function doSave($con)
  145. {
  146. $affectedRows = 0; if (!$this->alreadyInSave) {
  147. $this->alreadyInSave = true;
  148. if ($this->aFakeForum !== null) {
  149. if ($this->aFakeForum->isModified() || ($this->aFakeForum->getCulture() && $this->aFakeForum->getCurrentFakeForumI18n()->isModified())) {
  150. $affectedRows += $this->aFakeForum->save($con);
  151. }
  152. $this->setFakeForum($this->aFakeForum);
  153. }
  154. if ($this->isModified()) {
  155. if ($this->isNew()) {
  156. $pk = FakeForumI18nPeer::doInsert($this, $con);
  157. $affectedRows += 1;
  158. $this->setNew(false);
  159. } else {
  160. $affectedRows += FakeForumI18nPeer::doUpdate($this, $con);
  161. }
  162. $this->resetModified(); }
  163. $this->alreadyInSave = false;
  164. }
  165. return $affectedRows;
  166. }
  167. protected $validationFailures = array();
  168. public function getValidationFailures()
  169. {
  170. return $this->validationFailures;
  171. }
  172. public function validate($columns = null)
  173. {
  174. $res = $this->doValidate($columns);
  175. if ($res === true) {
  176. $this->validationFailures = array();
  177. return true;
  178. } else {
  179. $this->validationFailures = $res;
  180. return false;
  181. }
  182. }
  183. protected function doValidate($columns = null)
  184. {
  185. if (!$this->alreadyInValidation) {
  186. $this->alreadyInValidation = true;
  187. $retval = null;
  188. $failureMap = array();
  189. if ($this->aFakeForum !== null) {
  190. if (!$this->aFakeForum->validate($columns)) {
  191. $failureMap = array_merge($failureMap, $this->aFakeForum->getValidationFailures());
  192. }
  193. }
  194. if (($retval = FakeForumI18nPeer::doValidate($this, $columns)) !== true) {
  195. $failureMap = array_merge($failureMap, $retval);
  196. }
  197. $this->alreadyInValidation = false;
  198. }
  199. return (!empty($failureMap) ? $failureMap : true);
  200. }
  201. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  202. {
  203. $pos = FakeForumI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  204. return $this->getByPosition($pos);
  205. }
  206. public function getByPosition($pos)
  207. {
  208. switch($pos) {
  209. case 0:
  210. return $this->getTitle();
  211. break;
  212. case 1:
  213. return $this->getDescription();
  214. break;
  215. case 2:
  216. return $this->getId();
  217. break;
  218. case 3:
  219. return $this->getCulture();
  220. break;
  221. default:
  222. return null;
  223. break;
  224. } }
  225. public function toArray($keyType = BasePeer::TYPE_PHPNAME)
  226. {
  227. $keys = FakeForumI18nPeer::getFieldNames($keyType);
  228. $result = array(
  229. $keys[0] => $this->getTitle(),
  230. $keys[1] => $this->getDescription(),
  231. $keys[2] => $this->getId(),
  232. $keys[3] => $this->getCulture(),
  233. );
  234. return $result;
  235. }
  236. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  237. {
  238. $pos = FakeForumI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  239. return $this->setByPosition($pos, $value);
  240. }
  241. public function setByPosition($pos, $value)
  242. {
  243. switch($pos) {
  244. case 0:
  245. $this->setTitle($value);
  246. break;
  247. case 1:
  248. $this->setDescription($value);
  249. break;
  250. case 2:
  251. $this->setId($value);
  252. break;
  253. case 3:
  254. $this->setCulture($value);
  255. break;
  256. } }
  257. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  258. {
  259. $keys = FakeForumI18nPeer::getFieldNames($keyType);
  260. if (array_key_exists($keys[0], $arr)) $this->setTitle($arr[$keys[0]]);
  261. if (array_key_exists($keys[1], $arr)) $this->setDescription($arr[$keys[1]]);
  262. if (array_key_exists($keys[2], $arr)) $this->setId($arr[$keys[2]]);
  263. if (array_key_exists($keys[3], $arr)) $this->setCulture($arr[$keys[3]]);
  264. }
  265. public function buildCriteria()
  266. {
  267. $criteria = new Criteria(FakeForumI18nPeer::DATABASE_NAME);
  268. if ($this->isColumnModified(FakeForumI18nPeer::TITLE)) $criteria->add(FakeForumI18nPeer::TITLE, $this->title);
  269. if ($this->isColumnModified(FakeForumI18nPeer::DESCRIPTION)) $criteria->add(FakeForumI18nPeer::DESCRIPTION, $this->description);
  270. if ($this->isColumnModified(FakeForumI18nPeer::ID)) $criteria->add(FakeForumI18nPeer::ID, $this->id);
  271. if ($this->isColumnModified(FakeForumI18nPeer::CULTURE)) $criteria->add(FakeForumI18nPeer::CULTURE, $this->culture);
  272. return $criteria;
  273. }
  274. public function buildPkeyCriteria()
  275. {
  276. $criteria = new Criteria(FakeForumI18nPeer::DATABASE_NAME);
  277. $criteria->add(FakeForumI18nPeer::ID, $this->id);
  278. $criteria->add(FakeForumI18nPeer::CULTURE, $this->culture);
  279. return $criteria;
  280. }
  281. public function getPrimaryKey()
  282. {
  283. $pks = array();
  284. $pks[0] = $this->getId();
  285. $pks[1] = $this->getCulture();
  286. return $pks;
  287. }
  288. public function setPrimaryKey($keys)
  289. {
  290. $this->setId($keys[0]);
  291. $this->setCulture($keys[1]);
  292. }
  293. public function copyInto($copyObj, $deepCopy = false)
  294. {
  295. $copyObj->setTitle($this->title);
  296. $copyObj->setDescription($this->description);
  297. $copyObj->setNew(true);
  298. $copyObj->setId(NULL);
  299. $copyObj->setCulture(NULL);
  300. }
  301. public function copy($deepCopy = false)
  302. {
  303. $clazz = get_class($this);
  304. $copyObj = new $clazz();
  305. $this->copyInto($copyObj, $deepCopy);
  306. return $copyObj;
  307. }
  308. public function getPeer()
  309. {
  310. if (self::$peer === null) {
  311. self::$peer = new FakeForumI18nPeer();
  312. }
  313. return self::$peer;
  314. }
  315. public function setFakeForum($v)
  316. {
  317. if ($v === null) {
  318. $this->setId(NULL);
  319. } else {
  320. $this->setId($v->getId());
  321. }
  322. $this->aFakeForum = $v;
  323. }
  324. public function getFakeForum($con = null)
  325. {
  326. if ($this->aFakeForum === null && ($this->id !== null)) {
  327. $this->aFakeForum = FakeForumPeer::retrieveByPK($this->id, $con);
  328. }
  329. return $this->aFakeForum;
  330. }
  331. public function __call($method, $arguments)
  332. {
  333. if (!$callable = sfMixer::getCallable('BaseFakeForumI18n:'.$method))
  334. {
  335. throw new sfException(sprintf('Call to undefined method BaseFakeForumI18n::%s', $method));
  336. }
  337. array_unshift($arguments, $this);
  338. return call_user_func_array($callable, $arguments);
  339. }
  340. }