1: <?php
2:
3: namespace Thelia\Model\om;
4:
5: use \BaseObject;
6: use \BasePeer;
7: use \Criteria;
8: use \Exception;
9: use \PDO;
10: use \Persistent;
11: use \Propel;
12: use \PropelException;
13: use \PropelPDO;
14: use Thelia\Model\TaxRule;
15: use Thelia\Model\TaxRuleI18n;
16: use Thelia\Model\TaxRuleI18nPeer;
17: use Thelia\Model\TaxRuleI18nQuery;
18: use Thelia\Model\TaxRuleQuery;
19:
20: /**
21: * Base class that represents a row from the 'tax_rule_i18n' table.
22: *
23: *
24: *
25: * @package propel.generator.Thelia.Model.om
26: */
27: abstract class BaseTaxRuleI18n extends BaseObject implements Persistent
28: {
29: /**
30: * Peer class name
31: */
32: const PEER = 'Thelia\\Model\\TaxRuleI18nPeer';
33:
34: /**
35: * The Peer class.
36: * Instance provides a convenient way of calling static methods on a class
37: * that calling code may not be able to identify.
38: * @var TaxRuleI18nPeer
39: */
40: protected static $peer;
41:
42: /**
43: * The flag var to prevent infinit loop in deep copy
44: * @var boolean
45: */
46: protected $startCopy = false;
47:
48: /**
49: * The value for the id field.
50: * @var int
51: */
52: protected $id;
53:
54: /**
55: * The value for the locale field.
56: * Note: this column has a database default value of: 'en_EN'
57: * @var string
58: */
59: protected $locale;
60:
61: /**
62: * @var TaxRule
63: */
64: protected $aTaxRule;
65:
66: /**
67: * Flag to prevent endless save loop, if this object is referenced
68: * by another object which falls in this transaction.
69: * @var boolean
70: */
71: protected $alreadyInSave = false;
72:
73: /**
74: * Flag to prevent endless validation loop, if this object is referenced
75: * by another object which falls in this transaction.
76: * @var boolean
77: */
78: protected $alreadyInValidation = false;
79:
80: /**
81: * Applies default values to this object.
82: * This method should be called from the object's constructor (or
83: * equivalent initialization method).
84: * @see __construct()
85: */
86: public function applyDefaultValues()
87: {
88: $this->locale = 'en_EN';
89: }
90:
91: /**
92: * Initializes internal state of BaseTaxRuleI18n object.
93: * @see applyDefaults()
94: */
95: public function __construct()
96: {
97: parent::__construct();
98: $this->applyDefaultValues();
99: }
100:
101: /**
102: * Get the [id] column value.
103: *
104: * @return int
105: */
106: public function getId()
107: {
108: return $this->id;
109: }
110:
111: /**
112: * Get the [locale] column value.
113: *
114: * @return string
115: */
116: public function getLocale()
117: {
118: return $this->locale;
119: }
120:
121: /**
122: * Set the value of [id] column.
123: *
124: * @param int $v new value
125: * @return TaxRuleI18n The current object (for fluent API support)
126: */
127: public function setId($v)
128: {
129: if ($v !== null) {
130: $v = (int) $v;
131: }
132:
133: if ($this->id !== $v) {
134: $this->id = $v;
135: $this->modifiedColumns[] = TaxRuleI18nPeer::ID;
136: }
137:
138: if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) {
139: $this->aTaxRule = null;
140: }
141:
142:
143: return $this;
144: } // setId()
145:
146: /**
147: * Set the value of [locale] column.
148: *
149: * @param string $v new value
150: * @return TaxRuleI18n The current object (for fluent API support)
151: */
152: public function setLocale($v)
153: {
154: if ($v !== null) {
155: $v = (string) $v;
156: }
157:
158: if ($this->locale !== $v) {
159: $this->locale = $v;
160: $this->modifiedColumns[] = TaxRuleI18nPeer::LOCALE;
161: }
162:
163:
164: return $this;
165: } // setLocale()
166:
167: /**
168: * Indicates whether the columns in this object are only set to default values.
169: *
170: * This method can be used in conjunction with isModified() to indicate whether an object is both
171: * modified _and_ has some values set which are non-default.
172: *
173: * @return boolean Whether the columns in this object are only been set with default values.
174: */
175: public function hasOnlyDefaultValues()
176: {
177: if ($this->locale !== 'en_EN') {
178: return false;
179: }
180:
181: // otherwise, everything was equal, so return true
182: return true;
183: } // hasOnlyDefaultValues()
184:
185: /**
186: * Hydrates (populates) the object variables with values from the database resultset.
187: *
188: * An offset (0-based "start column") is specified so that objects can be hydrated
189: * with a subset of the columns in the resultset rows. This is needed, for example,
190: * for results of JOIN queries where the resultset row includes columns from two or
191: * more tables.
192: *
193: * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
194: * @param int $startcol 0-based offset column which indicates which restultset column to start with.
195: * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
196: * @return int next starting column
197: * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
198: */
199: public function hydrate($row, $startcol = 0, $rehydrate = false)
200: {
201: try {
202:
203: $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
204: $this->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
205: $this->resetModified();
206:
207: $this->setNew(false);
208:
209: if ($rehydrate) {
210: $this->ensureConsistency();
211: }
212:
213: return $startcol + 2; // 2 = TaxRuleI18nPeer::NUM_HYDRATE_COLUMNS.
214:
215: } catch (Exception $e) {
216: throw new PropelException("Error populating TaxRuleI18n object", $e);
217: }
218: }
219:
220: /**
221: * Checks and repairs the internal consistency of the object.
222: *
223: * This method is executed after an already-instantiated object is re-hydrated
224: * from the database. It exists to check any foreign keys to make sure that
225: * the objects related to the current object are correct based on foreign key.
226: *
227: * You can override this method in the stub class, but you should always invoke
228: * the base method from the overridden method (i.e. parent::ensureConsistency()),
229: * in case your model changes.
230: *
231: * @throws PropelException
232: */
233: public function ensureConsistency()
234: {
235:
236: if ($this->aTaxRule !== null && $this->id !== $this->aTaxRule->getId()) {
237: $this->aTaxRule = null;
238: }
239: } // ensureConsistency
240:
241: /**
242: * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
243: *
244: * This will only work if the object has been saved and has a valid primary key set.
245: *
246: * @param boolean $deep (optional) Whether to also de-associated any related objects.
247: * @param PropelPDO $con (optional) The PropelPDO connection to use.
248: * @return void
249: * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
250: */
251: public function reload($deep = false, PropelPDO $con = null)
252: {
253: if ($this->isDeleted()) {
254: throw new PropelException("Cannot reload a deleted object.");
255: }
256:
257: if ($this->isNew()) {
258: throw new PropelException("Cannot reload an unsaved object.");
259: }
260:
261: if ($con === null) {
262: $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
263: }
264:
265: // We don't need to alter the object instance pool; we're just modifying this instance
266: // already in the pool.
267:
268: $stmt = TaxRuleI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
269: $row = $stmt->fetch(PDO::FETCH_NUM);
270: $stmt->closeCursor();
271: if (!$row) {
272: throw new PropelException('Cannot find matching row in the database to reload object values.');
273: }
274: $this->hydrate($row, 0, true); // rehydrate
275:
276: if ($deep) { // also de-associate any related objects?
277:
278: $this->aTaxRule = null;
279: } // if (deep)
280: }
281:
282: /**
283: * Removes this object from datastore and sets delete attribute.
284: *
285: * @param PropelPDO $con
286: * @return void
287: * @throws PropelException
288: * @throws Exception
289: * @see BaseObject::setDeleted()
290: * @see BaseObject::isDeleted()
291: */
292: public function delete(PropelPDO $con = null)
293: {
294: if ($this->isDeleted()) {
295: throw new PropelException("This object has already been deleted.");
296: }
297:
298: if ($con === null) {
299: $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
300: }
301:
302: $con->beginTransaction();
303: try {
304: $deleteQuery = TaxRuleI18nQuery::create()
305: ->filterByPrimaryKey($this->getPrimaryKey());
306: $ret = $this->preDelete($con);
307: if ($ret) {
308: $deleteQuery->delete($con);
309: $this->postDelete($con);
310: $con->commit();
311: $this->setDeleted(true);
312: } else {
313: $con->commit();
314: }
315: } catch (Exception $e) {
316: $con->rollBack();
317: throw $e;
318: }
319: }
320:
321: /**
322: * Persists this object to the database.
323: *
324: * If the object is new, it inserts it; otherwise an update is performed.
325: * All modified related objects will also be persisted in the doSave()
326: * method. This method wraps all precipitate database operations in a
327: * single transaction.
328: *
329: * @param PropelPDO $con
330: * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
331: * @throws PropelException
332: * @throws Exception
333: * @see doSave()
334: */
335: public function save(PropelPDO $con = null)
336: {
337: if ($this->isDeleted()) {
338: throw new PropelException("You cannot save an object that has been deleted.");
339: }
340:
341: if ($con === null) {
342: $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
343: }
344:
345: $con->beginTransaction();
346: $isInsert = $this->isNew();
347: try {
348: $ret = $this->preSave($con);
349: if ($isInsert) {
350: $ret = $ret && $this->preInsert($con);
351: } else {
352: $ret = $ret && $this->preUpdate($con);
353: }
354: if ($ret) {
355: $affectedRows = $this->doSave($con);
356: if ($isInsert) {
357: $this->postInsert($con);
358: } else {
359: $this->postUpdate($con);
360: }
361: $this->postSave($con);
362: TaxRuleI18nPeer::addInstanceToPool($this);
363: } else {
364: $affectedRows = 0;
365: }
366: $con->commit();
367:
368: return $affectedRows;
369: } catch (Exception $e) {
370: $con->rollBack();
371: throw $e;
372: }
373: }
374:
375: /**
376: * Performs the work of inserting or updating the row in the database.
377: *
378: * If the object is new, it inserts it; otherwise an update is performed.
379: * All related objects are also updated in this method.
380: *
381: * @param PropelPDO $con
382: * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
383: * @throws PropelException
384: * @see save()
385: */
386: protected function doSave(PropelPDO $con)
387: {
388: $affectedRows = 0; // initialize var to track total num of affected rows
389: if (!$this->alreadyInSave) {
390: $this->alreadyInSave = true;
391:
392: // We call the save method on the following object(s) if they
393: // were passed to this object by their coresponding set
394: // method. This object relates to these object(s) by a
395: // foreign key reference.
396:
397: if ($this->aTaxRule !== null) {
398: if ($this->aTaxRule->isModified() || $this->aTaxRule->isNew()) {
399: $affectedRows += $this->aTaxRule->save($con);
400: }
401: $this->setTaxRule($this->aTaxRule);
402: }
403:
404: if ($this->isNew() || $this->isModified()) {
405: // persist changes
406: if ($this->isNew()) {
407: $this->doInsert($con);
408: } else {
409: $this->doUpdate($con);
410: }
411: $affectedRows += 1;
412: $this->resetModified();
413: }
414:
415: $this->alreadyInSave = false;
416:
417: }
418:
419: return $affectedRows;
420: } // doSave()
421:
422: /**
423: * Insert the row in the database.
424: *
425: * @param PropelPDO $con
426: *
427: * @throws PropelException
428: * @see doSave()
429: */
430: protected function doInsert(PropelPDO $con)
431: {
432: $modifiedColumns = array();
433: $index = 0;
434:
435:
436: // check the columns in natural order for more readable SQL queries
437: if ($this->isColumnModified(TaxRuleI18nPeer::ID)) {
438: $modifiedColumns[':p' . $index++] = '`ID`';
439: }
440: if ($this->isColumnModified(TaxRuleI18nPeer::LOCALE)) {
441: $modifiedColumns[':p' . $index++] = '`LOCALE`';
442: }
443:
444: $sql = sprintf(
445: 'INSERT INTO `tax_rule_i18n` (%s) VALUES (%s)',
446: implode(', ', $modifiedColumns),
447: implode(', ', array_keys($modifiedColumns))
448: );
449:
450: try {
451: $stmt = $con->prepare($sql);
452: foreach ($modifiedColumns as $identifier => $columnName) {
453: switch ($columnName) {
454: case '`ID`':
455: $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
456: break;
457: case '`LOCALE`':
458: $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
459: break;
460: }
461: }
462: $stmt->execute();
463: } catch (Exception $e) {
464: Propel::log($e->getMessage(), Propel::LOG_ERR);
465: throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
466: }
467:
468: $this->setNew(false);
469: }
470:
471: /**
472: * Update the row in the database.
473: *
474: * @param PropelPDO $con
475: *
476: * @see doSave()
477: */
478: protected function doUpdate(PropelPDO $con)
479: {
480: $selectCriteria = $this->buildPkeyCriteria();
481: $valuesCriteria = $this->buildCriteria();
482: BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
483: }
484:
485: /**
486: * Array of ValidationFailed objects.
487: * @var array ValidationFailed[]
488: */
489: protected $validationFailures = array();
490:
491: /**
492: * Gets any ValidationFailed objects that resulted from last call to validate().
493: *
494: *
495: * @return array ValidationFailed[]
496: * @see validate()
497: */
498: public function getValidationFailures()
499: {
500: return $this->validationFailures;
501: }
502:
503: /**
504: * Validates the objects modified field values and all objects related to this table.
505: *
506: * If $columns is either a column name or an array of column names
507: * only those columns are validated.
508: *
509: * @param mixed $columns Column name or an array of column names.
510: * @return boolean Whether all columns pass validation.
511: * @see doValidate()
512: * @see getValidationFailures()
513: */
514: public function validate($columns = null)
515: {
516: $res = $this->doValidate($columns);
517: if ($res === true) {
518: $this->validationFailures = array();
519:
520: return true;
521: } else {
522: $this->validationFailures = $res;
523:
524: return false;
525: }
526: }
527:
528: /**
529: * This function performs the validation work for complex object models.
530: *
531: * In addition to checking the current object, all related objects will
532: * also be validated. If all pass then <code>true</code> is returned; otherwise
533: * an aggreagated array of ValidationFailed objects will be returned.
534: *
535: * @param array $columns Array of column names to validate.
536: * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
537: */
538: protected function doValidate($columns = null)
539: {
540: if (!$this->alreadyInValidation) {
541: $this->alreadyInValidation = true;
542: $retval = null;
543:
544: $failureMap = array();
545:
546:
547: // We call the validate method on the following object(s) if they
548: // were passed to this object by their coresponding set
549: // method. This object relates to these object(s) by a
550: // foreign key reference.
551:
552: if ($this->aTaxRule !== null) {
553: if (!$this->aTaxRule->validate($columns)) {
554: $failureMap = array_merge($failureMap, $this->aTaxRule->getValidationFailures());
555: }
556: }
557:
558:
559: if (($retval = TaxRuleI18nPeer::doValidate($this, $columns)) !== true) {
560: $failureMap = array_merge($failureMap, $retval);
561: }
562:
563:
564:
565: $this->alreadyInValidation = false;
566: }
567:
568: return (!empty($failureMap) ? $failureMap : true);
569: }
570:
571: /**
572: * Retrieves a field from the object by name passed in as a string.
573: *
574: * @param string $name name
575: * @param string $type The type of fieldname the $name is of:
576: * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
577: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
578: * Defaults to BasePeer::TYPE_PHPNAME
579: * @return mixed Value of field.
580: */
581: public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
582: {
583: $pos = TaxRuleI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
584: $field = $this->getByPosition($pos);
585:
586: return $field;
587: }
588:
589: /**
590: * Retrieves a field from the object by Position as specified in the xml schema.
591: * Zero-based.
592: *
593: * @param int $pos position in xml schema
594: * @return mixed Value of field at $pos
595: */
596: public function getByPosition($pos)
597: {
598: switch ($pos) {
599: case 0:
600: return $this->getId();
601: break;
602: case 1:
603: return $this->getLocale();
604: break;
605: default:
606: return null;
607: break;
608: } // switch()
609: }
610:
611: /**
612: * Exports the object as an array.
613: *
614: * You can specify the key type of the array by passing one of the class
615: * type constants.
616: *
617: * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
618: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
619: * Defaults to BasePeer::TYPE_PHPNAME.
620: * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
621: * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
622: * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
623: *
624: * @return array an associative array containing the field names (as keys) and field values
625: */
626: public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
627: {
628: if (isset($alreadyDumpedObjects['TaxRuleI18n'][serialize($this->getPrimaryKey())])) {
629: return '*RECURSION*';
630: }
631: $alreadyDumpedObjects['TaxRuleI18n'][serialize($this->getPrimaryKey())] = true;
632: $keys = TaxRuleI18nPeer::getFieldNames($keyType);
633: $result = array(
634: $keys[0] => $this->getId(),
635: $keys[1] => $this->getLocale(),
636: );
637: if ($includeForeignObjects) {
638: if (null !== $this->aTaxRule) {
639: $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
640: }
641: }
642:
643: return $result;
644: }
645:
646: /**
647: * Sets a field from the object by name passed in as a string.
648: *
649: * @param string $name peer name
650: * @param mixed $value field value
651: * @param string $type The type of fieldname the $name is of:
652: * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
653: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
654: * Defaults to BasePeer::TYPE_PHPNAME
655: * @return void
656: */
657: public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
658: {
659: $pos = TaxRuleI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
660:
661: $this->setByPosition($pos, $value);
662: }
663:
664: /**
665: * Sets a field from the object by Position as specified in the xml schema.
666: * Zero-based.
667: *
668: * @param int $pos position in xml schema
669: * @param mixed $value field value
670: * @return void
671: */
672: public function setByPosition($pos, $value)
673: {
674: switch ($pos) {
675: case 0:
676: $this->setId($value);
677: break;
678: case 1:
679: $this->setLocale($value);
680: break;
681: } // switch()
682: }
683:
684: /**
685: * Populates the object using an array.
686: *
687: * This is particularly useful when populating an object from one of the
688: * request arrays (e.g. $_POST). This method goes through the column
689: * names, checking to see whether a matching key exists in populated
690: * array. If so the setByName() method is called for that column.
691: *
692: * You can specify the key type of the array by additionally passing one
693: * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
694: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
695: * The default key type is the column's BasePeer::TYPE_PHPNAME
696: *
697: * @param array $arr An array to populate the object from.
698: * @param string $keyType The type of keys the array uses.
699: * @return void
700: */
701: public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
702: {
703: $keys = TaxRuleI18nPeer::getFieldNames($keyType);
704:
705: if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
706: if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
707: }
708:
709: /**
710: * Build a Criteria object containing the values of all modified columns in this object.
711: *
712: * @return Criteria The Criteria object containing all modified values.
713: */
714: public function buildCriteria()
715: {
716: $criteria = new Criteria(TaxRuleI18nPeer::DATABASE_NAME);
717:
718: if ($this->isColumnModified(TaxRuleI18nPeer::ID)) $criteria->add(TaxRuleI18nPeer::ID, $this->id);
719: if ($this->isColumnModified(TaxRuleI18nPeer::LOCALE)) $criteria->add(TaxRuleI18nPeer::LOCALE, $this->locale);
720:
721: return $criteria;
722: }
723:
724: /**
725: * Builds a Criteria object containing the primary key for this object.
726: *
727: * Unlike buildCriteria() this method includes the primary key values regardless
728: * of whether or not they have been modified.
729: *
730: * @return Criteria The Criteria object containing value(s) for primary key(s).
731: */
732: public function buildPkeyCriteria()
733: {
734: $criteria = new Criteria(TaxRuleI18nPeer::DATABASE_NAME);
735: $criteria->add(TaxRuleI18nPeer::ID, $this->id);
736: $criteria->add(TaxRuleI18nPeer::LOCALE, $this->locale);
737:
738: return $criteria;
739: }
740:
741: /**
742: * Returns the composite primary key for this object.
743: * The array elements will be in same order as specified in XML.
744: * @return array
745: */
746: public function getPrimaryKey()
747: {
748: $pks = array();
749: $pks[0] = $this->getId();
750: $pks[1] = $this->getLocale();
751:
752: return $pks;
753: }
754:
755: /**
756: * Set the [composite] primary key.
757: *
758: * @param array $keys The elements of the composite key (order must match the order in XML file).
759: * @return void
760: */
761: public function setPrimaryKey($keys)
762: {
763: $this->setId($keys[0]);
764: $this->setLocale($keys[1]);
765: }
766:
767: /**
768: * Returns true if the primary key for this object is null.
769: * @return boolean
770: */
771: public function isPrimaryKeyNull()
772: {
773:
774: return (null === $this->getId()) && (null === $this->getLocale());
775: }
776:
777: /**
778: * Sets contents of passed object to values from current object.
779: *
780: * If desired, this method can also make copies of all associated (fkey referrers)
781: * objects.
782: *
783: * @param object $copyObj An object of TaxRuleI18n (or compatible) type.
784: * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
785: * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
786: * @throws PropelException
787: */
788: public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
789: {
790: $copyObj->setId($this->getId());
791: $copyObj->setLocale($this->getLocale());
792:
793: if ($deepCopy && !$this->startCopy) {
794: // important: temporarily setNew(false) because this affects the behavior of
795: // the getter/setter methods for fkey referrer objects.
796: $copyObj->setNew(false);
797: // store object hash to prevent cycle
798: $this->startCopy = true;
799:
800: //unflag object copy
801: $this->startCopy = false;
802: } // if ($deepCopy)
803:
804: if ($makeNew) {
805: $copyObj->setNew(true);
806: }
807: }
808:
809: /**
810: * Makes a copy of this object that will be inserted as a new row in table when saved.
811: * It creates a new object filling in the simple attributes, but skipping any primary
812: * keys that are defined for the table.
813: *
814: * If desired, this method can also make copies of all associated (fkey referrers)
815: * objects.
816: *
817: * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
818: * @return TaxRuleI18n Clone of current object.
819: * @throws PropelException
820: */
821: public function copy($deepCopy = false)
822: {
823: // we use get_class(), because this might be a subclass
824: $clazz = get_class($this);
825: $copyObj = new $clazz();
826: $this->copyInto($copyObj, $deepCopy);
827:
828: return $copyObj;
829: }
830:
831: /**
832: * Returns a peer instance associated with this om.
833: *
834: * Since Peer classes are not to have any instance attributes, this method returns the
835: * same instance for all member of this class. The method could therefore
836: * be static, but this would prevent one from overriding the behavior.
837: *
838: * @return TaxRuleI18nPeer
839: */
840: public function getPeer()
841: {
842: if (self::$peer === null) {
843: self::$peer = new TaxRuleI18nPeer();
844: }
845:
846: return self::$peer;
847: }
848:
849: /**
850: * Declares an association between this object and a TaxRule object.
851: *
852: * @param TaxRule $v
853: * @return TaxRuleI18n The current object (for fluent API support)
854: * @throws PropelException
855: */
856: public function setTaxRule(TaxRule $v = null)
857: {
858: if ($v === null) {
859: $this->setId(NULL);
860: } else {
861: $this->setId($v->getId());
862: }
863:
864: $this->aTaxRule = $v;
865:
866: // Add binding for other direction of this n:n relationship.
867: // If this object has already been added to the TaxRule object, it will not be re-added.
868: if ($v !== null) {
869: $v->addTaxRuleI18n($this);
870: }
871:
872:
873: return $this;
874: }
875:
876:
877: /**
878: * Get the associated TaxRule object
879: *
880: * @param PropelPDO $con Optional Connection object.
881: * @return TaxRule The associated TaxRule object.
882: * @throws PropelException
883: */
884: public function getTaxRule(PropelPDO $con = null)
885: {
886: if ($this->aTaxRule === null && ($this->id !== null)) {
887: $this->aTaxRule = TaxRuleQuery::create()->findPk($this->id, $con);
888: /* The following can be used additionally to
889: guarantee the related object contains a reference
890: to this object. This level of coupling may, however, be
891: undesirable since it could result in an only partially populated collection
892: in the referenced object.
893: $this->aTaxRule->addTaxRuleI18ns($this);
894: */
895: }
896:
897: return $this->aTaxRule;
898: }
899:
900: /**
901: * Clears the current object and sets all attributes to their default values
902: */
903: public function clear()
904: {
905: $this->id = null;
906: $this->locale = null;
907: $this->alreadyInSave = false;
908: $this->alreadyInValidation = false;
909: $this->clearAllReferences();
910: $this->applyDefaultValues();
911: $this->resetModified();
912: $this->setNew(true);
913: $this->setDeleted(false);
914: }
915:
916: /**
917: * Resets all references to other model objects or collections of model objects.
918: *
919: * This method is a user-space workaround for PHP's inability to garbage collect
920: * objects with circular references (even in PHP 5.3). This is currently necessary
921: * when using Propel in certain daemon or large-volumne/high-memory operations.
922: *
923: * @param boolean $deep Whether to also clear the references on all referrer objects.
924: */
925: public function clearAllReferences($deep = false)
926: {
927: if ($deep) {
928: } // if ($deep)
929:
930: $this->aTaxRule = null;
931: }
932:
933: /**
934: * return the string representation of this object
935: *
936: * @return string
937: */
938: public function __toString()
939: {
940: return (string) $this->exportTo(TaxRuleI18nPeer::DEFAULT_STRING_FORMAT);
941: }
942:
943: /**
944: * return true is the object is in saving state
945: *
946: * @return boolean
947: */
948: public function isAlreadyInSave()
949: {
950: return $this->alreadyInSave;
951: }
952:
953: }
954: