PageRenderTime 58ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/package/app/app/alpha/lib/model/om/BasePermissionItem.php

https://bitbucket.org/pandaos/kaltura
PHP | 1834 lines | 920 code | 241 blank | 673 comment | 162 complexity | 563113c5f416ba1a21ef6e6ac1624cd0 MD5 | raw file
Possible License(s): AGPL-3.0, GPL-3.0, BSD-3-Clause, LGPL-2.1, GPL-2.0, LGPL-3.0, JSON, MPL-2.0-no-copyleft-exception, Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * Base class that represents a row from the 'permission_item' table.
  4. *
  5. *
  6. *
  7. * @package Core
  8. * @subpackage model.om
  9. */
  10. abstract class BasePermissionItem extends BaseObject implements Persistent {
  11. /**
  12. * The Peer class.
  13. * Instance provides a convenient way of calling static methods on a class
  14. * that calling code may not be able to identify.
  15. * @var PermissionItemPeer
  16. */
  17. protected static $peer;
  18. /**
  19. * The value for the id field.
  20. * @var int
  21. */
  22. protected $id;
  23. /**
  24. * The value for the type field.
  25. * @var string
  26. */
  27. protected $type;
  28. /**
  29. * The value for the partner_id field.
  30. * @var int
  31. */
  32. protected $partner_id;
  33. /**
  34. * The value for the param_1 field.
  35. * @var string
  36. */
  37. protected $param_1;
  38. /**
  39. * The value for the param_2 field.
  40. * @var string
  41. */
  42. protected $param_2;
  43. /**
  44. * The value for the param_3 field.
  45. * @var string
  46. */
  47. protected $param_3;
  48. /**
  49. * The value for the param_4 field.
  50. * @var string
  51. */
  52. protected $param_4;
  53. /**
  54. * The value for the param_5 field.
  55. * @var string
  56. */
  57. protected $param_5;
  58. /**
  59. * The value for the tags field.
  60. * @var string
  61. */
  62. protected $tags;
  63. /**
  64. * The value for the created_at field.
  65. * @var string
  66. */
  67. protected $created_at;
  68. /**
  69. * The value for the updated_at field.
  70. * @var string
  71. */
  72. protected $updated_at;
  73. /**
  74. * The value for the custom_data field.
  75. * @var string
  76. */
  77. protected $custom_data;
  78. /**
  79. * @var array PermissionToPermissionItem[] Collection to store aggregation of PermissionToPermissionItem objects.
  80. */
  81. protected $collPermissionToPermissionItems;
  82. /**
  83. * @var Criteria The criteria used to select the current contents of collPermissionToPermissionItems.
  84. */
  85. private $lastPermissionToPermissionItemCriteria = null;
  86. /**
  87. * Flag to prevent endless save loop, if this object is referenced
  88. * by another object which falls in this transaction.
  89. * @var boolean
  90. */
  91. protected $alreadyInSave = false;
  92. /**
  93. * Flag to prevent endless validation loop, if this object is referenced
  94. * by another object which falls in this transaction.
  95. * @var boolean
  96. */
  97. protected $alreadyInValidation = false;
  98. /**
  99. * Store columns old values before the changes
  100. * @var array
  101. */
  102. protected $oldColumnsValues = array();
  103. /**
  104. * @return array
  105. */
  106. public function getColumnsOldValues()
  107. {
  108. return $this->oldColumnsValues;
  109. }
  110. /**
  111. * Get the [id] column value.
  112. *
  113. * @return int
  114. */
  115. public function getId()
  116. {
  117. return $this->id;
  118. }
  119. /**
  120. * Get the [type] column value.
  121. *
  122. * @return string
  123. */
  124. public function getType()
  125. {
  126. return $this->type;
  127. }
  128. /**
  129. * Get the [partner_id] column value.
  130. *
  131. * @return int
  132. */
  133. public function getPartnerId()
  134. {
  135. return $this->partner_id;
  136. }
  137. /**
  138. * Get the [param_1] column value.
  139. *
  140. * @return string
  141. */
  142. public function getParam1()
  143. {
  144. return $this->param_1;
  145. }
  146. /**
  147. * Get the [param_2] column value.
  148. *
  149. * @return string
  150. */
  151. public function getParam2()
  152. {
  153. return $this->param_2;
  154. }
  155. /**
  156. * Get the [param_3] column value.
  157. *
  158. * @return string
  159. */
  160. public function getParam3()
  161. {
  162. return $this->param_3;
  163. }
  164. /**
  165. * Get the [param_4] column value.
  166. *
  167. * @return string
  168. */
  169. public function getParam4()
  170. {
  171. return $this->param_4;
  172. }
  173. /**
  174. * Get the [param_5] column value.
  175. *
  176. * @return string
  177. */
  178. public function getParam5()
  179. {
  180. return $this->param_5;
  181. }
  182. /**
  183. * Get the [tags] column value.
  184. *
  185. * @return string
  186. */
  187. public function getTags()
  188. {
  189. return $this->tags;
  190. }
  191. /**
  192. * Get the [optionally formatted] temporal [created_at] column value.
  193. *
  194. * This accessor only only work with unix epoch dates. Consider enabling the propel.useDateTimeClass
  195. * option in order to avoid converstions to integers (which are limited in the dates they can express).
  196. *
  197. * @param string $format The date/time format string (either date()-style or strftime()-style).
  198. * If format is NULL, then the raw unix timestamp integer will be returned.
  199. * @return mixed Formatted date/time value as string or (integer) unix timestamp (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
  200. * @throws PropelException - if unable to parse/validate the date/time value.
  201. */
  202. public function getCreatedAt($format = 'Y-m-d H:i:s')
  203. {
  204. if ($this->created_at === null) {
  205. return null;
  206. }
  207. if ($this->created_at === '0000-00-00 00:00:00') {
  208. // while technically this is not a default value of NULL,
  209. // this seems to be closest in meaning.
  210. return null;
  211. } else {
  212. try {
  213. $dt = new DateTime($this->created_at);
  214. } catch (Exception $x) {
  215. throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
  216. }
  217. }
  218. if ($format === null) {
  219. // We cast here to maintain BC in API; obviously we will lose data if we're dealing with pre-/post-epoch dates.
  220. return (int) $dt->format('U');
  221. } elseif (strpos($format, '%') !== false) {
  222. return strftime($format, $dt->format('U'));
  223. } else {
  224. return $dt->format($format);
  225. }
  226. }
  227. /**
  228. * Get the [optionally formatted] temporal [updated_at] column value.
  229. *
  230. * This accessor only only work with unix epoch dates. Consider enabling the propel.useDateTimeClass
  231. * option in order to avoid converstions to integers (which are limited in the dates they can express).
  232. *
  233. * @param string $format The date/time format string (either date()-style or strftime()-style).
  234. * If format is NULL, then the raw unix timestamp integer will be returned.
  235. * @return mixed Formatted date/time value as string or (integer) unix timestamp (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
  236. * @throws PropelException - if unable to parse/validate the date/time value.
  237. */
  238. public function getUpdatedAt($format = 'Y-m-d H:i:s')
  239. {
  240. if ($this->updated_at === null) {
  241. return null;
  242. }
  243. if ($this->updated_at === '0000-00-00 00:00:00') {
  244. // while technically this is not a default value of NULL,
  245. // this seems to be closest in meaning.
  246. return null;
  247. } else {
  248. try {
  249. $dt = new DateTime($this->updated_at);
  250. } catch (Exception $x) {
  251. throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
  252. }
  253. }
  254. if ($format === null) {
  255. // We cast here to maintain BC in API; obviously we will lose data if we're dealing with pre-/post-epoch dates.
  256. return (int) $dt->format('U');
  257. } elseif (strpos($format, '%') !== false) {
  258. return strftime($format, $dt->format('U'));
  259. } else {
  260. return $dt->format($format);
  261. }
  262. }
  263. /**
  264. * Get the [custom_data] column value.
  265. *
  266. * @return string
  267. */
  268. public function getCustomData()
  269. {
  270. return $this->custom_data;
  271. }
  272. /**
  273. * Set the value of [id] column.
  274. *
  275. * @param int $v new value
  276. * @return PermissionItem The current object (for fluent API support)
  277. */
  278. public function setId($v)
  279. {
  280. if(!isset($this->oldColumnsValues[PermissionItemPeer::ID]))
  281. $this->oldColumnsValues[PermissionItemPeer::ID] = $this->id;
  282. if ($v !== null) {
  283. $v = (int) $v;
  284. }
  285. if ($this->id !== $v) {
  286. $this->id = $v;
  287. $this->modifiedColumns[] = PermissionItemPeer::ID;
  288. }
  289. return $this;
  290. } // setId()
  291. /**
  292. * Set the value of [type] column.
  293. *
  294. * @param string $v new value
  295. * @return PermissionItem The current object (for fluent API support)
  296. */
  297. public function setType($v)
  298. {
  299. if(!isset($this->oldColumnsValues[PermissionItemPeer::TYPE]))
  300. $this->oldColumnsValues[PermissionItemPeer::TYPE] = $this->type;
  301. if ($v !== null) {
  302. $v = (string) $v;
  303. }
  304. if ($this->type !== $v) {
  305. $this->type = $v;
  306. $this->modifiedColumns[] = PermissionItemPeer::TYPE;
  307. }
  308. return $this;
  309. } // setType()
  310. /**
  311. * Set the value of [partner_id] column.
  312. *
  313. * @param int $v new value
  314. * @return PermissionItem The current object (for fluent API support)
  315. */
  316. public function setPartnerId($v)
  317. {
  318. if(!isset($this->oldColumnsValues[PermissionItemPeer::PARTNER_ID]))
  319. $this->oldColumnsValues[PermissionItemPeer::PARTNER_ID] = $this->partner_id;
  320. if ($v !== null) {
  321. $v = (int) $v;
  322. }
  323. if ($this->partner_id !== $v) {
  324. $this->partner_id = $v;
  325. $this->modifiedColumns[] = PermissionItemPeer::PARTNER_ID;
  326. }
  327. return $this;
  328. } // setPartnerId()
  329. /**
  330. * Set the value of [param_1] column.
  331. *
  332. * @param string $v new value
  333. * @return PermissionItem The current object (for fluent API support)
  334. */
  335. public function setParam1($v)
  336. {
  337. if(!isset($this->oldColumnsValues[PermissionItemPeer::PARAM_1]))
  338. $this->oldColumnsValues[PermissionItemPeer::PARAM_1] = $this->param_1;
  339. if ($v !== null) {
  340. $v = (string) $v;
  341. }
  342. if ($this->param_1 !== $v) {
  343. $this->param_1 = $v;
  344. $this->modifiedColumns[] = PermissionItemPeer::PARAM_1;
  345. }
  346. return $this;
  347. } // setParam1()
  348. /**
  349. * Set the value of [param_2] column.
  350. *
  351. * @param string $v new value
  352. * @return PermissionItem The current object (for fluent API support)
  353. */
  354. public function setParam2($v)
  355. {
  356. if(!isset($this->oldColumnsValues[PermissionItemPeer::PARAM_2]))
  357. $this->oldColumnsValues[PermissionItemPeer::PARAM_2] = $this->param_2;
  358. if ($v !== null) {
  359. $v = (string) $v;
  360. }
  361. if ($this->param_2 !== $v) {
  362. $this->param_2 = $v;
  363. $this->modifiedColumns[] = PermissionItemPeer::PARAM_2;
  364. }
  365. return $this;
  366. } // setParam2()
  367. /**
  368. * Set the value of [param_3] column.
  369. *
  370. * @param string $v new value
  371. * @return PermissionItem The current object (for fluent API support)
  372. */
  373. public function setParam3($v)
  374. {
  375. if(!isset($this->oldColumnsValues[PermissionItemPeer::PARAM_3]))
  376. $this->oldColumnsValues[PermissionItemPeer::PARAM_3] = $this->param_3;
  377. if ($v !== null) {
  378. $v = (string) $v;
  379. }
  380. if ($this->param_3 !== $v) {
  381. $this->param_3 = $v;
  382. $this->modifiedColumns[] = PermissionItemPeer::PARAM_3;
  383. }
  384. return $this;
  385. } // setParam3()
  386. /**
  387. * Set the value of [param_4] column.
  388. *
  389. * @param string $v new value
  390. * @return PermissionItem The current object (for fluent API support)
  391. */
  392. public function setParam4($v)
  393. {
  394. if(!isset($this->oldColumnsValues[PermissionItemPeer::PARAM_4]))
  395. $this->oldColumnsValues[PermissionItemPeer::PARAM_4] = $this->param_4;
  396. if ($v !== null) {
  397. $v = (string) $v;
  398. }
  399. if ($this->param_4 !== $v) {
  400. $this->param_4 = $v;
  401. $this->modifiedColumns[] = PermissionItemPeer::PARAM_4;
  402. }
  403. return $this;
  404. } // setParam4()
  405. /**
  406. * Set the value of [param_5] column.
  407. *
  408. * @param string $v new value
  409. * @return PermissionItem The current object (for fluent API support)
  410. */
  411. public function setParam5($v)
  412. {
  413. if(!isset($this->oldColumnsValues[PermissionItemPeer::PARAM_5]))
  414. $this->oldColumnsValues[PermissionItemPeer::PARAM_5] = $this->param_5;
  415. if ($v !== null) {
  416. $v = (string) $v;
  417. }
  418. if ($this->param_5 !== $v) {
  419. $this->param_5 = $v;
  420. $this->modifiedColumns[] = PermissionItemPeer::PARAM_5;
  421. }
  422. return $this;
  423. } // setParam5()
  424. /**
  425. * Set the value of [tags] column.
  426. *
  427. * @param string $v new value
  428. * @return PermissionItem The current object (for fluent API support)
  429. */
  430. public function setTags($v)
  431. {
  432. if(!isset($this->oldColumnsValues[PermissionItemPeer::TAGS]))
  433. $this->oldColumnsValues[PermissionItemPeer::TAGS] = $this->tags;
  434. if ($v !== null) {
  435. $v = (string) $v;
  436. }
  437. if ($this->tags !== $v) {
  438. $this->tags = $v;
  439. $this->modifiedColumns[] = PermissionItemPeer::TAGS;
  440. }
  441. return $this;
  442. } // setTags()
  443. /**
  444. * Sets the value of [created_at] column to a normalized version of the date/time value specified.
  445. *
  446. * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
  447. * be treated as NULL for temporal objects.
  448. * @return PermissionItem The current object (for fluent API support)
  449. */
  450. public function setCreatedAt($v)
  451. {
  452. // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  453. // -- which is unexpected, to say the least.
  454. if ($v === null || $v === '') {
  455. $dt = null;
  456. } elseif ($v instanceof DateTime) {
  457. $dt = $v;
  458. } else {
  459. // some string/numeric value passed; we normalize that so that we can
  460. // validate it.
  461. try {
  462. if (is_numeric($v)) { // if it's a unix timestamp
  463. $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
  464. // We have to explicitly specify and then change the time zone because of a
  465. // DateTime bug: http://bugs.php.net/bug.php?id=43003
  466. $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  467. } else {
  468. $dt = new DateTime($v);
  469. }
  470. } catch (Exception $x) {
  471. throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
  472. }
  473. }
  474. if ( $this->created_at !== null || $dt !== null ) {
  475. // (nested ifs are a little easier to read in this case)
  476. $currNorm = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
  477. $newNorm = ($dt !== null) ? $dt->format('Y-m-d H:i:s') : null;
  478. if ( ($currNorm !== $newNorm) // normalized values don't match
  479. )
  480. {
  481. $this->created_at = ($dt ? $dt->format('Y-m-d H:i:s') : null);
  482. $this->modifiedColumns[] = PermissionItemPeer::CREATED_AT;
  483. }
  484. } // if either are not null
  485. return $this;
  486. } // setCreatedAt()
  487. /**
  488. * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
  489. *
  490. * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
  491. * be treated as NULL for temporal objects.
  492. * @return PermissionItem The current object (for fluent API support)
  493. */
  494. public function setUpdatedAt($v)
  495. {
  496. // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  497. // -- which is unexpected, to say the least.
  498. if ($v === null || $v === '') {
  499. $dt = null;
  500. } elseif ($v instanceof DateTime) {
  501. $dt = $v;
  502. } else {
  503. // some string/numeric value passed; we normalize that so that we can
  504. // validate it.
  505. try {
  506. if (is_numeric($v)) { // if it's a unix timestamp
  507. $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
  508. // We have to explicitly specify and then change the time zone because of a
  509. // DateTime bug: http://bugs.php.net/bug.php?id=43003
  510. $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  511. } else {
  512. $dt = new DateTime($v);
  513. }
  514. } catch (Exception $x) {
  515. throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
  516. }
  517. }
  518. if ( $this->updated_at !== null || $dt !== null ) {
  519. // (nested ifs are a little easier to read in this case)
  520. $currNorm = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
  521. $newNorm = ($dt !== null) ? $dt->format('Y-m-d H:i:s') : null;
  522. if ( ($currNorm !== $newNorm) // normalized values don't match
  523. )
  524. {
  525. $this->updated_at = ($dt ? $dt->format('Y-m-d H:i:s') : null);
  526. $this->modifiedColumns[] = PermissionItemPeer::UPDATED_AT;
  527. }
  528. } // if either are not null
  529. return $this;
  530. } // setUpdatedAt()
  531. /**
  532. * Set the value of [custom_data] column.
  533. *
  534. * @param string $v new value
  535. * @return PermissionItem The current object (for fluent API support)
  536. */
  537. public function setCustomData($v)
  538. {
  539. if ($v !== null) {
  540. $v = (string) $v;
  541. }
  542. if ($this->custom_data !== $v) {
  543. $this->custom_data = $v;
  544. $this->modifiedColumns[] = PermissionItemPeer::CUSTOM_DATA;
  545. }
  546. return $this;
  547. } // setCustomData()
  548. /**
  549. * Indicates whether the columns in this object are only set to default values.
  550. *
  551. * This method can be used in conjunction with isModified() to indicate whether an object is both
  552. * modified _and_ has some values set which are non-default.
  553. *
  554. * @return boolean Whether the columns in this object are only been set with default values.
  555. */
  556. public function hasOnlyDefaultValues()
  557. {
  558. // otherwise, everything was equal, so return TRUE
  559. return true;
  560. } // hasOnlyDefaultValues()
  561. /**
  562. * Hydrates (populates) the object variables with values from the database resultset.
  563. *
  564. * An offset (0-based "start column") is specified so that objects can be hydrated
  565. * with a subset of the columns in the resultset rows. This is needed, for example,
  566. * for results of JOIN queries where the resultset row includes columns from two or
  567. * more tables.
  568. *
  569. * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
  570. * @param int $startcol 0-based offset column which indicates which restultset column to start with.
  571. * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
  572. * @return int next starting column
  573. * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
  574. */
  575. public function hydrate($row, $startcol = 0, $rehydrate = false)
  576. {
  577. try {
  578. $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
  579. $this->type = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
  580. $this->partner_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
  581. $this->param_1 = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
  582. $this->param_2 = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
  583. $this->param_3 = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
  584. $this->param_4 = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
  585. $this->param_5 = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
  586. $this->tags = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
  587. $this->created_at = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
  588. $this->updated_at = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
  589. $this->custom_data = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null;
  590. $this->resetModified();
  591. $this->setNew(false);
  592. if ($rehydrate) {
  593. $this->ensureConsistency();
  594. }
  595. // FIXME - using NUM_COLUMNS may be clearer.
  596. return $startcol + 12; // 12 = PermissionItemPeer::NUM_COLUMNS - PermissionItemPeer::NUM_LAZY_LOAD_COLUMNS).
  597. } catch (Exception $e) {
  598. throw new PropelException("Error populating PermissionItem object", $e);
  599. }
  600. }
  601. /**
  602. * Checks and repairs the internal consistency of the object.
  603. *
  604. * This method is executed after an already-instantiated object is re-hydrated
  605. * from the database. It exists to check any foreign keys to make sure that
  606. * the objects related to the current object are correct based on foreign key.
  607. *
  608. * You can override this method in the stub class, but you should always invoke
  609. * the base method from the overridden method (i.e. parent::ensureConsistency()),
  610. * in case your model changes.
  611. *
  612. * @throws PropelException
  613. */
  614. public function ensureConsistency()
  615. {
  616. } // ensureConsistency
  617. /**
  618. * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
  619. *
  620. * This will only work if the object has been saved and has a valid primary key set.
  621. *
  622. * @param boolean $deep (optional) Whether to also de-associated any related objects.
  623. * @param PropelPDO $con (optional) The PropelPDO connection to use.
  624. * @return void
  625. * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
  626. */
  627. public function reload($deep = false, PropelPDO $con = null)
  628. {
  629. if ($this->isDeleted()) {
  630. throw new PropelException("Cannot reload a deleted object.");
  631. }
  632. if ($this->isNew()) {
  633. throw new PropelException("Cannot reload an unsaved object.");
  634. }
  635. if ($con === null) {
  636. $con = Propel::getConnection(PermissionItemPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  637. }
  638. // We don't need to alter the object instance pool; we're just modifying this instance
  639. // already in the pool.
  640. PermissionItemPeer::setUseCriteriaFilter(false);
  641. $stmt = PermissionItemPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
  642. PermissionItemPeer::setUseCriteriaFilter(true);
  643. $row = $stmt->fetch(PDO::FETCH_NUM);
  644. $stmt->closeCursor();
  645. if (!$row) {
  646. throw new PropelException('Cannot find matching row in the database to reload object values.');
  647. }
  648. $this->hydrate($row, 0, true); // rehydrate
  649. if ($deep) { // also de-associate any related objects?
  650. $this->collPermissionToPermissionItems = null;
  651. $this->lastPermissionToPermissionItemCriteria = null;
  652. } // if (deep)
  653. }
  654. /**
  655. * Removes this object from datastore and sets delete attribute.
  656. *
  657. * @param PropelPDO $con
  658. * @return void
  659. * @throws PropelException
  660. * @see BaseObject::setDeleted()
  661. * @see BaseObject::isDeleted()
  662. */
  663. public function delete(PropelPDO $con = null)
  664. {
  665. if ($this->isDeleted()) {
  666. throw new PropelException("This object has already been deleted.");
  667. }
  668. if ($con === null) {
  669. $con = Propel::getConnection(PermissionItemPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  670. }
  671. $con->beginTransaction();
  672. try {
  673. $ret = $this->preDelete($con);
  674. if ($ret) {
  675. PermissionItemPeer::doDelete($this, $con);
  676. $this->postDelete($con);
  677. $this->setDeleted(true);
  678. $con->commit();
  679. } else {
  680. $con->commit();
  681. }
  682. } catch (PropelException $e) {
  683. $con->rollBack();
  684. throw $e;
  685. }
  686. }
  687. /**
  688. * Persists this object to the database.
  689. *
  690. * If the object is new, it inserts it; otherwise an update is performed.
  691. * All modified related objects will also be persisted in the doSave()
  692. * method. This method wraps all precipitate database operations in a
  693. * single transaction.
  694. *
  695. * @param PropelPDO $con
  696. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  697. * @throws PropelException
  698. * @see doSave()
  699. */
  700. public function save(PropelPDO $con = null)
  701. {
  702. if ($this->isDeleted()) {
  703. throw new PropelException("You cannot save an object that has been deleted.");
  704. }
  705. if ($con === null) {
  706. $con = Propel::getConnection(PermissionItemPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  707. }
  708. $con->beginTransaction();
  709. $isInsert = $this->isNew();
  710. try {
  711. $ret = $this->preSave($con);
  712. if ($isInsert) {
  713. $ret = $ret && $this->preInsert($con);
  714. } else {
  715. $ret = $ret && $this->preUpdate($con);
  716. }
  717. if ($ret) {
  718. $affectedRows = $this->doSave($con);
  719. if ($isInsert) {
  720. $this->postInsert($con);
  721. } else {
  722. $this->postUpdate($con);
  723. }
  724. $this->postSave($con);
  725. PermissionItemPeer::addInstanceToPool($this);
  726. } else {
  727. $affectedRows = 0;
  728. }
  729. $con->commit();
  730. return $affectedRows;
  731. } catch (PropelException $e) {
  732. $con->rollBack();
  733. throw $e;
  734. }
  735. }
  736. /**
  737. * Performs the work of inserting or updating the row in the database.
  738. *
  739. * If the object is new, it inserts it; otherwise an update is performed.
  740. * All related objects are also updated in this method.
  741. *
  742. * @param PropelPDO $con
  743. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  744. * @throws PropelException
  745. * @see save()
  746. */
  747. protected function doSave(PropelPDO $con)
  748. {
  749. $affectedRows = 0; // initialize var to track total num of affected rows
  750. if (!$this->alreadyInSave) {
  751. $this->alreadyInSave = true;
  752. if ($this->isNew() ) {
  753. $this->modifiedColumns[] = PermissionItemPeer::ID;
  754. }
  755. // If this object has been modified, then save it to the database.
  756. if ($this->isModified()) {
  757. if ($this->isNew()) {
  758. $pk = PermissionItemPeer::doInsert($this, $con);
  759. $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
  760. // should always be true here (even though technically
  761. // BasePeer::doInsert() can insert multiple rows).
  762. $this->setId($pk); //[IMV] update autoincrement primary key
  763. $this->setNew(false);
  764. } else {
  765. $affectedRows += PermissionItemPeer::doUpdate($this, $con);
  766. }
  767. $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
  768. }
  769. if ($this->collPermissionToPermissionItems !== null) {
  770. foreach ($this->collPermissionToPermissionItems as $referrerFK) {
  771. if (!$referrerFK->isDeleted()) {
  772. $affectedRows += $referrerFK->save($con);
  773. }
  774. }
  775. }
  776. $this->alreadyInSave = false;
  777. }
  778. return $affectedRows;
  779. } // doSave()
  780. /**
  781. * Override in order to use the query cache.
  782. * Cache invalidation keys are used to determine when cached queries are valid.
  783. * Before returning a query result from the cache, the time of the cached query
  784. * is compared to the time saved in the invalidation key.
  785. * A cached query will only be used if it's newer than the matching invalidation key.
  786. *
  787. * @return array Array of keys that will should be updated when this object is modified.
  788. */
  789. public function getCacheInvalidationKeys()
  790. {
  791. return array();
  792. }
  793. /**
  794. * Code to be run before persisting the object
  795. * @param PropelPDO $con
  796. * @return bloolean
  797. */
  798. public function preSave(PropelPDO $con = null)
  799. {
  800. $this->setCustomDataObj();
  801. return parent::preSave($con);
  802. }
  803. /**
  804. * Code to be run after persisting the object
  805. * @param PropelPDO $con
  806. */
  807. public function postSave(PropelPDO $con = null)
  808. {
  809. $this->oldColumnsValues = array();
  810. $this->oldCustomDataValues = array();
  811. }
  812. /**
  813. * Code to be run before inserting to database
  814. * @param PropelPDO $con
  815. * @return boolean
  816. */
  817. public function preInsert(PropelPDO $con = null)
  818. {
  819. $this->setCreatedAt(time());
  820. $this->setUpdatedAt(time());
  821. return true;
  822. }
  823. /**
  824. * Code to be run after inserting to database
  825. * @param PropelPDO $con
  826. */
  827. public function postInsert(PropelPDO $con = null)
  828. {
  829. kQueryCache::invalidateQueryCache($this);
  830. kEventsManager::raiseEvent(new kObjectCreatedEvent($this));
  831. if($this->copiedFrom)
  832. kEventsManager::raiseEvent(new kObjectCopiedEvent($this->copiedFrom, $this));
  833. }
  834. /**
  835. * Code to be run after updating the object in database
  836. * @param PropelPDO $con
  837. */
  838. public function postUpdate(PropelPDO $con = null)
  839. {
  840. if ($this->alreadyInSave)
  841. {
  842. return;
  843. }
  844. if($this->isModified())
  845. {
  846. kQueryCache::invalidateQueryCache($this);
  847. kEventsManager::raiseEvent(new kObjectChangedEvent($this, $this->tempModifiedColumns));
  848. }
  849. $this->tempModifiedColumns = array();
  850. }
  851. /**
  852. * Saves the modified columns temporarily while saving
  853. * @var array
  854. */
  855. private $tempModifiedColumns = array();
  856. /**
  857. * Returns whether the object has been modified.
  858. *
  859. * @return boolean True if the object has been modified.
  860. */
  861. public function isModified()
  862. {
  863. if(!empty($this->tempModifiedColumns))
  864. return true;
  865. return !empty($this->modifiedColumns);
  866. }
  867. /**
  868. * Has specified column been modified?
  869. *
  870. * @param string $col
  871. * @return boolean True if $col has been modified.
  872. */
  873. public function isColumnModified($col)
  874. {
  875. if(in_array($col, $this->tempModifiedColumns))
  876. return true;
  877. return in_array($col, $this->modifiedColumns);
  878. }
  879. /**
  880. * Code to be run before updating the object in database
  881. * @param PropelPDO $con
  882. * @return boolean
  883. */
  884. public function preUpdate(PropelPDO $con = null)
  885. {
  886. if ($this->alreadyInSave)
  887. {
  888. return true;
  889. }
  890. if($this->isModified())
  891. $this->setUpdatedAt(time());
  892. $this->tempModifiedColumns = $this->modifiedColumns;
  893. return true;
  894. }
  895. /**
  896. * Array of ValidationFailed objects.
  897. * @var array ValidationFailed[]
  898. */
  899. protected $validationFailures = array();
  900. /**
  901. * Gets any ValidationFailed objects that resulted from last call to validate().
  902. *
  903. *
  904. * @return array ValidationFailed[]
  905. * @see validate()
  906. */
  907. public function getValidationFailures()
  908. {
  909. return $this->validationFailures;
  910. }
  911. /**
  912. * Validates the objects modified field values and all objects related to this table.
  913. *
  914. * If $columns is either a column name or an array of column names
  915. * only those columns are validated.
  916. *
  917. * @param mixed $columns Column name or an array of column names.
  918. * @return boolean Whether all columns pass validation.
  919. * @see doValidate()
  920. * @see getValidationFailures()
  921. */
  922. public function validate($columns = null)
  923. {
  924. $res = $this->doValidate($columns);
  925. if ($res === true) {
  926. $this->validationFailures = array();
  927. return true;
  928. } else {
  929. $this->validationFailures = $res;
  930. return false;
  931. }
  932. }
  933. /**
  934. * This function performs the validation work for complex object models.
  935. *
  936. * In addition to checking the current object, all related objects will
  937. * also be validated. If all pass then <code>true</code> is returned; otherwise
  938. * an aggreagated array of ValidationFailed objects will be returned.
  939. *
  940. * @param array $columns Array of column names to validate.
  941. * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  942. */
  943. protected function doValidate($columns = null)
  944. {
  945. if (!$this->alreadyInValidation) {
  946. $this->alreadyInValidation = true;
  947. $retval = null;
  948. $failureMap = array();
  949. if (($retval = PermissionItemPeer::doValidate($this, $columns)) !== true) {
  950. $failureMap = array_merge($failureMap, $retval);
  951. }
  952. if ($this->collPermissionToPermissionItems !== null) {
  953. foreach ($this->collPermissionToPermissionItems as $referrerFK) {
  954. if (!$referrerFK->validate($columns)) {
  955. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  956. }
  957. }
  958. }
  959. $this->alreadyInValidation = false;
  960. }
  961. return (!empty($failureMap) ? $failureMap : true);
  962. }
  963. /**
  964. * Retrieves a field from the object by name passed in as a string.
  965. *
  966. * @param string $name name
  967. * @param string $type The type of fieldname the $name is of:
  968. * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  969. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  970. * @return mixed Value of field.
  971. */
  972. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  973. {
  974. $pos = PermissionItemPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  975. $field = $this->getByPosition($pos);
  976. return $field;
  977. }
  978. /**
  979. * Retrieves a field from the object by Position as specified in the xml schema.
  980. * Zero-based.
  981. *
  982. * @param int $pos position in xml schema
  983. * @return mixed Value of field at $pos
  984. */
  985. public function getByPosition($pos)
  986. {
  987. switch($pos) {
  988. case 0:
  989. return $this->getId();
  990. break;
  991. case 1:
  992. return $this->getType();
  993. break;
  994. case 2:
  995. return $this->getPartnerId();
  996. break;
  997. case 3:
  998. return $this->getParam1();
  999. break;
  1000. case 4:
  1001. return $this->getParam2();
  1002. break;
  1003. case 5:
  1004. return $this->getParam3();
  1005. break;
  1006. case 6:
  1007. return $this->getParam4();
  1008. break;
  1009. case 7:
  1010. return $this->getParam5();
  1011. break;
  1012. case 8:
  1013. return $this->getTags();
  1014. break;
  1015. case 9:
  1016. return $this->getCreatedAt();
  1017. break;
  1018. case 10:
  1019. return $this->getUpdatedAt();
  1020. break;
  1021. case 11:
  1022. return $this->getCustomData();
  1023. break;
  1024. default:
  1025. return null;
  1026. break;
  1027. } // switch()
  1028. }
  1029. /**
  1030. * Exports the object as an array.
  1031. *
  1032. * You can specify the key type of the array by passing one of the class
  1033. * type constants.
  1034. *
  1035. * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  1036. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. Defaults to BasePeer::TYPE_PHPNAME.
  1037. * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  1038. * @return an associative array containing the field names (as keys) and field values
  1039. */
  1040. public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
  1041. {
  1042. $keys = PermissionItemPeer::getFieldNames($keyType);
  1043. $result = array(
  1044. $keys[0] => $this->getId(),
  1045. $keys[1] => $this->getType(),
  1046. $keys[2] => $this->getPartnerId(),
  1047. $keys[3] => $this->getParam1(),
  1048. $keys[4] => $this->getParam2(),
  1049. $keys[5] => $this->getParam3(),
  1050. $keys[6] => $this->getParam4(),
  1051. $keys[7] => $this->getParam5(),
  1052. $keys[8] => $this->getTags(),
  1053. $keys[9] => $this->getCreatedAt(),
  1054. $keys[10] => $this->getUpdatedAt(),
  1055. $keys[11] => $this->getCustomData(),
  1056. );
  1057. return $result;
  1058. }
  1059. /**
  1060. * Sets a field from the object by name passed in as a string.
  1061. *
  1062. * @param string $name peer name
  1063. * @param mixed $value field value
  1064. * @param string $type The type of fieldname the $name is of:
  1065. * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  1066. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  1067. * @return void
  1068. */
  1069. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  1070. {
  1071. $pos = PermissionItemPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  1072. return $this->setByPosition($pos, $value);
  1073. }
  1074. /**
  1075. * Sets a field from the object by Position as specified in the xml schema.
  1076. * Zero-based.
  1077. *
  1078. * @param int $pos position in xml schema
  1079. * @param mixed $value field value
  1080. * @return void
  1081. */
  1082. public function setByPosition($pos, $value)
  1083. {
  1084. switch($pos) {
  1085. case 0:
  1086. $this->setId($value);
  1087. break;
  1088. case 1:
  1089. $this->setType($value);
  1090. break;
  1091. case 2:
  1092. $this->setPartnerId($value);
  1093. break;
  1094. case 3:
  1095. $this->setParam1($value);
  1096. break;
  1097. case 4:
  1098. $this->setParam2($value);
  1099. break;
  1100. case 5:
  1101. $this->setParam3($value);
  1102. break;
  1103. case 6:
  1104. $this->setParam4($value);
  1105. break;
  1106. case 7:
  1107. $this->setParam5($value);
  1108. break;
  1109. case 8:
  1110. $this->setTags($value);
  1111. break;
  1112. case 9:
  1113. $this->setCreatedAt($value);
  1114. break;
  1115. case 10:
  1116. $this->setUpdatedAt($value);
  1117. break;
  1118. case 11:
  1119. $this->setCustomData($value);
  1120. break;
  1121. } // switch()
  1122. }
  1123. /**
  1124. * Populates the object using an array.
  1125. *
  1126. * This is particularly useful when populating an object from one of the
  1127. * request arrays (e.g. $_POST). This method goes through the column
  1128. * names, checking to see whether a matching key exists in populated
  1129. * array. If so the setByName() method is called for that column.
  1130. *
  1131. * You can specify the key type of the array by additionally passing one
  1132. * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  1133. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  1134. * The default key type is the column's phpname (e.g. 'AuthorId')
  1135. *
  1136. * @param array $arr An array to populate the object from.
  1137. * @param string $keyType The type of keys the array uses.
  1138. * @return void
  1139. */
  1140. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  1141. {
  1142. $keys = PermissionItemPeer::getFieldNames($keyType);
  1143. if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
  1144. if (array_key_exists($keys[1], $arr)) $this->setType($arr[$keys[1]]);
  1145. if (array_key_exists($keys[2], $arr)) $this->setPartnerId($arr[$keys[2]]);
  1146. if (array_key_exists($keys[3], $arr)) $this->setParam1($arr[$keys[3]]);
  1147. if (array_key_exists($keys[4], $arr)) $this->setParam2($arr[$keys[4]]);
  1148. if (array_key_exists($keys[5], $arr)) $this->setParam3($arr[$keys[5]]);
  1149. if (array_key_exists($keys[6], $arr)) $this->setParam4($arr[$keys[6]]);
  1150. if (array_key_exists($keys[7], $arr)) $this->setParam5($arr[$keys[7]]);
  1151. if (array_key_exists($keys[8], $arr)) $this->setTags($arr[$keys[8]]);
  1152. if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]);
  1153. if (array_key_exists($keys[10], $arr)) $this->setUpdatedAt($arr[$keys[10]]);
  1154. if (array_key_exists($keys[11], $arr)) $this->setCustomData($arr[$keys[11]]);
  1155. }
  1156. /**
  1157. * Build a Criteria object containing the values of all modified columns in this object.
  1158. *
  1159. * @return Criteria The Criteria object containing all modified values.
  1160. */
  1161. public function buildCriteria()
  1162. {
  1163. $criteria = new Criteria(PermissionItemPeer::DATABASE_NAME);
  1164. if ($this->isColumnModified(PermissionItemPeer::ID)) $criteria->add(PermissionItemPeer::ID, $this->id);
  1165. if ($this->isColumnModified(PermissionItemPeer::TYPE)) $criteria->add(PermissionItemPeer::TYPE, $this->type);
  1166. if ($this->isColumnModified(PermissionItemPeer::PARTNER_ID)) $criteria->add(PermissionItemPeer::PARTNER_ID, $this->partner_id);
  1167. if ($this->isColumnModified(PermissionItemPeer::PARAM_1)) $criteria->add(PermissionItemPeer::PARAM_1, $this->param_1);
  1168. if ($this->isColumnModified(PermissionItemPeer::PARAM_2)) $criteria->add(PermissionItemPeer::PARAM_2, $this->param_2);
  1169. if ($this->isColumnModified(PermissionItemPeer::PARAM_3)) $criteria->add(PermissionItemPeer::PARAM_3, $this->param_3);
  1170. if ($this->isColumnModified(PermissionItemPeer::PARAM_4)) $criteria->add(PermissionItemPeer::PARAM_4, $this->param_4);
  1171. if ($this->isColumnModified(PermissionItemPeer::PARAM_5)) $criteria->add(PermissionItemPeer::PARAM_5, $this->param_5);
  1172. if ($this->isColumnModified(PermissionItemPeer::TAGS)) $criteria->add(PermissionItemPeer::TAGS, $this->tags);
  1173. if ($this->isColumnModified(PermissionItemPeer::CREATED_AT)) $criteria->add(PermissionItemPeer::CREATED_AT, $this->created_at);
  1174. if ($this->isColumnModified(PermissionItemPeer::UPDATED_AT)) $criteria->add(PermissionItemPeer::UPDATED_AT, $this->updated_at);
  1175. if ($this->isColumnModified(PermissionItemPeer::CUSTOM_DATA)) $criteria->add(PermissionItemPeer::CUSTOM_DATA, $this->custom_data);
  1176. return $criteria;
  1177. }
  1178. /**
  1179. * Builds a Criteria object containing the primary key for this object.
  1180. *
  1181. * Unlike buildCriteria() this method includes the primary key values regardless
  1182. * of whether or not they have been modified.
  1183. *
  1184. * @return Criteria The Criteria object containing value(s) for primary key(s).
  1185. */
  1186. public function buildPkeyCriteria()
  1187. {
  1188. $criteria = new Criteria(PermissionItemPeer::DATABASE_NAME);
  1189. $criteria->add(PermissionItemPeer::ID, $this->id);
  1190. return $criteria;
  1191. }
  1192. /**
  1193. * Returns the primary key for this object (row).
  1194. * @return int
  1195. */
  1196. public function getPrimaryKey()
  1197. {
  1198. return $this->getId();
  1199. }
  1200. /**
  1201. * Generic method to set the primary key (id column).
  1202. *
  1203. * @param int $key Primary key.
  1204. * @return void
  1205. */
  1206. public function setPrimaryKey($key)
  1207. {
  1208. $this->setId($key);
  1209. }
  1210. /**
  1211. * Sets contents of passed object to values from current object.
  1212. *
  1213. * If desired, this method can also make copies of all associated (fkey referrers)
  1214. * objects.
  1215. *
  1216. * @param object $copyObj An object of PermissionItem (or compatible) type.
  1217. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1218. * @throws PropelException
  1219. */
  1220. public function copyInto($copyObj, $deepCopy = false)
  1221. {
  1222. $copyObj->setType($this->type);
  1223. $copyObj->setPartnerId($this->partner_id);
  1224. $copyObj->setParam1($this->param_1);
  1225. $copyObj->setParam2($this->param_2);
  1226. $copyObj->setParam3($this->param_3);
  1227. $copyObj->setParam4($this->param_4);
  1228. $copyObj->setParam5($this->param_5);
  1229. $copyObj->setTags($this->tags);
  1230. $copyObj->setCreatedAt($this->created_at);
  1231. $copyObj->setUpdatedAt($this->updated_at);
  1232. $copyObj->setCustomData($this->custom_data);
  1233. if ($deepCopy) {
  1234. // important: temporarily setNew(false) because this affects the behavior of
  1235. // the getter/setter methods for fkey referrer objects.
  1236. $copyObj->setNew(false);
  1237. foreach ($this->getPermissionToPermissionItems() as $relObj) {
  1238. if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
  1239. $copyObj->addPermissionToPermissionItem($relObj->copy($deepCopy));
  1240. }
  1241. }
  1242. } // if ($deepCopy)
  1243. $copyObj->setNew(true);
  1244. $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
  1245. }
  1246. /**
  1247. * Makes a copy of this object that will be inserted as a new row in table when saved.
  1248. * It creates a new object filling in the simple attributes, but skipping any primary
  1249. * keys that are defined for the table.
  1250. *
  1251. * If desired, this method can also make copies of all associated (fkey referrers)
  1252. * objects.
  1253. *
  1254. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1255. * @return PermissionItem Clone of current object.
  1256. * @throws PropelException
  1257. */
  1258. public function copy($deepCopy = false)
  1259. {
  1260. // we use get_class(), because this might be a subclass
  1261. $clazz = get_class($this);
  1262. $copyObj = new $clazz();
  1263. $this->copyInto($copyObj, $deepCopy);
  1264. $copyObj->setCopiedFrom($this);
  1265. return $copyObj;
  1266. }
  1267. /**
  1268. * Stores the source object that this object copied from
  1269. *
  1270. * @var PermissionItem Clone of current object.
  1271. */
  1272. protected $copiedFrom = null;
  1273. /**
  1274. * Stores the source object that this object copied from
  1275. *
  1276. * @param PermissionItem $copiedFrom Clone of current object.
  1277. */
  1278. public function setCopiedFrom(PermissionItem $copiedFrom)
  1279. {
  1280. $this->copiedFrom = $copiedFrom;
  1281. }
  1282. /**
  1283. * Returns a peer instance associated with this om.
  1284. *
  1285. * Since Peer classes are not to have any instance attributes, this method returns the
  1286. * same instance for all member of this class. The method could therefore
  1287. * be static, but this would prevent one from overriding the behavior.
  1288. *
  1289. * @return PermissionItemPeer
  1290. */
  1291. public function getPeer()
  1292. {
  1293. if (self::$peer === null) {
  1294. self::$peer = new PermissionItemPeer();
  1295. }
  1296. return self::$peer;
  1297. }
  1298. /**
  1299. * Clears out the collPermissionToPermissionItems collection (array).
  1300. *
  1301. * This does not modify the database; however, it will remove any associated objects, causing
  1302. * them to be refetched by subsequent calls to accessor method.
  1303. *
  1304. * @return void
  1305. * @see addPermissionToPermissionItems()
  1306. */
  1307. public function clearPermissionToPermissionItems()
  1308. {
  1309. $this->collPermissionToPermissionItems = null; // important to set this to NULL since that means it is uninitialized
  1310. }
  1311. /**
  1312. * Initializes the collPermissionToPermissionItems collection (array).
  1313. *
  1314. * By default this just sets the collPermissionToPermissionItems collection to an empty array (like clearcollPermissionToPermissionItems());
  1315. * however, you may wish to override this method in your stub class to provide setting appropriate
  1316. * to your application -- for example, setting the initial array to the values stored in database.
  1317. *
  1318. * @return void
  1319. */
  1320. public function initPermissionToPermissionItems()
  1321. {
  1322. $this->collPermissionToPermissionItems = array();
  1323. }
  1324. /**
  1325. * Gets an array of PermissionToPermissionItem objects which contain a foreign key that references this object.
  1326. *
  1327. * If this collection has already been initialized with an identical Criteria, it returns the collection.
  1328. * Otherwise if this PermissionItem has previously been saved, it will retrieve
  1329. * related PermissionToPermissionItems from storage. If this PermissionItem is new, it will return
  1330. * an empty collection or the current collection, the criteria is ignored on a new object.
  1331. *
  1332. * @param PropelPDO $con
  1333. * @param Criteria $criteria
  1334. * @return array PermissionToPermissionItem[]
  1335. * @throws PropelException
  1336. */
  1337. public function getPermissionToPermissionItems($criteria = null, PropelPDO $con = null)
  1338. {
  1339. if ($criteria === null) {
  1340. $criteria = new Criteria(PermissionItemPeer::DATABASE_NAME);
  1341. }
  1342. elseif ($criteria instanceof Criteria)
  1343. {
  1344. $criteria = clone $criteria;
  1345. }
  1346. if ($this->collPermissionToPermissionItems === null) {
  1347. if ($this->isNew()) {
  1348. $this->collPermissionToPermissionItems = array();
  1349. } else {
  1350. $criteria->add(PermissionToPermissionItemPeer::PERMISSION_ITEM_ID, $this->id);
  1351. PermissionToPermissionItemPeer::addSelectColumns($criteria);
  1352. $this->collPermissionToPermissionItems = PermissionToPermissionItemPeer::doSelect($criteria, $con);
  1353. }
  1354. } else {
  1355. // criteria has no effect for a new object
  1356. if (!$this->isNew()) {
  1357. // the following code is to determine if a new query is
  1358. // called for. If the criteria is the same as the last
  1359. // one, just return the collection.
  1360. $criteria->add(PermissionToPermissionItemPeer::PERMISSION_ITEM_ID, $this->id);
  1361. PermissionToPermissionItemPeer::addSelectColumns($criteria);
  1362. if (!isset($this->lastPermissionToPermissionItemCriteria) || !$this->lastPermissionToPermissionItemCriteria->equals($criteria)) {
  1363. $this->collPermissionToPermissionItems = PermissionToPermissionItemPeer::doSelect($criteria, $con);
  1364. }
  1365. }
  1366. }
  1367. $this->lastPermissionToPermissionItemCriteria = $criteria;
  1368. return $this->collPermissionToPermissionItems;
  1369. }
  1370. /**
  1371. * Returns the number of related PermissionToPermissionItem objects.
  1372. *
  1373. * @param Criteria $criteria
  1374. * @param boolean $distinct
  1375. * @param PropelPDO $con
  1376. * @return int Count of related PermissionToPermissionItem objects.
  1377. * @throws PropelException
  1378. */
  1379. public function countPermissionToPermissionItems(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
  1380. {
  1381. if ($criteria === null) {
  1382. $criteria = new Criteria(PermissionItemPeer::DATABASE_NAME);
  1383. } else {
  1384. $criteria = clone $criteria;
  1385. }
  1386. if ($distinct) {
  1387. $criteria->setDistinct();
  1388. }
  1389. $count = null;
  1390. if ($this->collPermissionToPermissionItems === null) {
  1391. if ($this->isNew()) {
  1392. $count = 0;
  1393. } else {
  1394. $criteria->add(PermissionToPermissionItemPeer::PERMISSION_ITEM_ID, $this->id);
  1395. $count = PermissionToPermissionItemPeer::doCount($criteria, false, $con);
  1396. }
  1397. } else {
  1398. // criteria has no effect for a new object
  1399. if (!$this->isNew()) {
  1400. // the following code is to determine if a new query is
  1401. // called for. If the criteria is the same as the last
  1402. // one, just return count of the collection.
  1403. $criteria->add(PermissionToPermissionItemPeer::PERMISSION_ITEM_ID, $this->id);
  1404. if (!isset($this->lastPermissionToPermissionItemCriteria) || !$this->lastPermissionToPermissionItemCriteria->equals($criteria)) {
  1405. $count = PermissionToPermissionItemPeer::doCount($criteria, false, $con);
  1406. } else {
  1407. $count = count($this->collPermissionToPermissionItems);
  1408. }
  1409. } else {
  1410. $count = count($this->collPermissionToPermissionItems);
  1411. }
  1412. }
  1413. return $count;
  1414. }
  1415. /**
  1416. * Method called to associate a PermissionToPermissionItem object to this object
  1417. * through the PermissionToPermissionItem foreign key attribute.
  1418. *
  1419. * @param PermissionToPermissionItem $l PermissionToPermissionItem
  1420. * @return void
  1421. * @throws PropelException
  1422. */
  1423. public function addPermissionToPermissionItem(PermissionToPermissionItem $l)
  1424. {
  1425. if ($this->collPermissionToPermissionItems === null) {
  1426. $this->initPermissionToPermissionItems();
  1427. }
  1428. if (!in_array($l, $this->collPermissionToPermissionItems, true)) { // only add it if the **same** object is not already associated
  1429. array_push($this->collPermissionToPermissionItems, $l);
  1430. $l->setPermissionItem($this);
  1431. }
  1432. }
  1433. /**
  1434. * If this collection has already been initialized with
  1435. * an identical criteria, it returns the collection.
  1436. * Otherwise if this PermissionItem is new, it will return
  1437. * an empty collection; or if this PermissionItem has previously
  1438. * been saved, it will retrieve related PermissionToPermissionItems from storage.
  1439. *
  1440. * This method is protected by default in order to keep the public
  1441. * api reasonable. You can provide public methods for those you
  1442. * actually need in PermissionItem.
  1443. */
  1444. public function getPermissionToPermissionItemsJoinPermission($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  1445. {
  1446. if ($criteria === null) {
  1447. $criteria = new Criteria(PermissionItemPeer::DATABASE_NAME);
  1448. }
  1449. elseif ($criteria instanceof Criteria)
  1450. {
  1451. $criteria = clone $criteria;
  1452. }
  1453. if ($this->collPermissionToPermissionItems === null) {
  1454. if ($this->isNew()) {
  1455. $this->collPermissionToPermissionItems = array();
  1456. } else {
  1457. $criteria->add(PermissionToPermissionItemPeer::PERMISSION_ITEM_ID, $this->id);
  1458. $this->collPermissionToPermissionItems = PermissionToPermissionItemPeer::doSelectJoinPermission($criteria, $con, $join_behavior);
  1459. }
  1460. } else {
  1461. // the following code is to determine if a new query is
  1462. // called for. If the criteria is the same as the last
  1463. // one, just return the collection.
  1464. $criteria->add(PermissionToPermissionItemPeer::PERMISSION_ITEM_ID, $this->id);
  1465. if (!isset($this->lastPermissionToPermissionItemCriteria) || !$this->lastPermissionToPermissionItemCriteria->equals($criteria)) {
  1466. $this->collPermissionToPermissionItems = PermissionToPermissionItemPeer::doSelectJoinPermission($criteria, $con, $join_behavior);
  1467. }
  1468. }
  1469. $this->lastPermissionToPermissionItemCriteria = $criteria;
  1470. return $this->collPermissionToPermissionItems;
  1471. }
  1472. /**
  1473. * Resets all collections of referencing foreign keys.
  1474. *
  1475. * This method is a user-space workaround for PHP's inability to garbage collect objects
  1476. * with circular references. This is currently necessary when using Propel in certain
  1477. * daemon or large-volumne/high-memory operations.
  1478. *
  1479. * @param boolean $deep Whether to also clear the references on all associated objects.
  1480. */
  1481. public function clearAllReferences($deep = false)
  1482. {
  1483. if ($deep) {

Large files files are truncated, but you can click here to view the full file