PageRenderTime 39ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/test/bin/model/om/BaseFakeForum.php

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