1: <?php
2:
3: namespace Thelia\Model\om;
4:
5: use \BaseObject;
6: use \BasePeer;
7: use \Criteria;
8: use \DateTime;
9: use \Exception;
10: use \PDO;
11: use \Persistent;
12: use \Propel;
13: use \PropelCollection;
14: use \PropelDateTime;
15: use \PropelException;
16: use \PropelObjectCollection;
17: use \PropelPDO;
18: use Thelia\Model\Feature;
19: use Thelia\Model\FeatureAv;
20: use Thelia\Model\FeatureAvI18n;
21: use Thelia\Model\FeatureAvI18nQuery;
22: use Thelia\Model\FeatureAvPeer;
23: use Thelia\Model\FeatureAvQuery;
24: use Thelia\Model\FeatureProd;
25: use Thelia\Model\FeatureProdQuery;
26: use Thelia\Model\FeatureQuery;
27:
28: /**
29: * Base class that represents a row from the 'feature_av' table.
30: *
31: *
32: *
33: * @package propel.generator.Thelia.Model.om
34: */
35: abstract class BaseFeatureAv extends BaseObject implements Persistent
36: {
37: /**
38: * Peer class name
39: */
40: const PEER = 'Thelia\\Model\\FeatureAvPeer';
41:
42: /**
43: * The Peer class.
44: * Instance provides a convenient way of calling static methods on a class
45: * that calling code may not be able to identify.
46: * @var FeatureAvPeer
47: */
48: protected static $peer;
49:
50: /**
51: * The flag var to prevent infinit loop in deep copy
52: * @var boolean
53: */
54: protected $startCopy = false;
55:
56: /**
57: * The value for the id field.
58: * @var int
59: */
60: protected $id;
61:
62: /**
63: * The value for the feature_id field.
64: * @var int
65: */
66: protected $feature_id;
67:
68: /**
69: * The value for the created_at field.
70: * @var string
71: */
72: protected $created_at;
73:
74: /**
75: * The value for the updated_at field.
76: * @var string
77: */
78: protected $updated_at;
79:
80: /**
81: * @var Feature
82: */
83: protected $aFeature;
84:
85: /**
86: * @var PropelObjectCollection|FeatureProd[] Collection to store aggregation of FeatureProd objects.
87: */
88: protected $collFeatureProds;
89: protected $collFeatureProdsPartial;
90:
91: /**
92: * @var PropelObjectCollection|FeatureAvI18n[] Collection to store aggregation of FeatureAvI18n objects.
93: */
94: protected $collFeatureAvI18ns;
95: protected $collFeatureAvI18nsPartial;
96:
97: /**
98: * Flag to prevent endless save loop, if this object is referenced
99: * by another object which falls in this transaction.
100: * @var boolean
101: */
102: protected $alreadyInSave = false;
103:
104: /**
105: * Flag to prevent endless validation loop, if this object is referenced
106: * by another object which falls in this transaction.
107: * @var boolean
108: */
109: protected $alreadyInValidation = false;
110:
111: // i18n behavior
112:
113: /**
114: * Current locale
115: * @var string
116: */
117: protected $currentLocale = 'en_EN';
118:
119: /**
120: * Current translation objects
121: * @var array[FeatureAvI18n]
122: */
123: protected $currentTranslations;
124:
125: /**
126: * An array of objects scheduled for deletion.
127: * @var PropelObjectCollection
128: */
129: protected $featureProdsScheduledForDeletion = null;
130:
131: /**
132: * An array of objects scheduled for deletion.
133: * @var PropelObjectCollection
134: */
135: protected $featureAvI18nsScheduledForDeletion = null;
136:
137: /**
138: * Get the [id] column value.
139: *
140: * @return int
141: */
142: public function getId()
143: {
144: return $this->id;
145: }
146:
147: /**
148: * Get the [feature_id] column value.
149: *
150: * @return int
151: */
152: public function getFeatureId()
153: {
154: return $this->feature_id;
155: }
156:
157: /**
158: * Get the [optionally formatted] temporal [created_at] column value.
159: *
160: *
161: * @param string $format The date/time format string (either date()-style or strftime()-style).
162: * If format is null, then the raw DateTime object will be returned.
163: * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
164: * @throws PropelException - if unable to parse/validate the date/time value.
165: */
166: public function getCreatedAt($format = 'Y-m-d H:i:s')
167: {
168: if ($this->created_at === null) {
169: return null;
170: }
171:
172: if ($this->created_at === '0000-00-00 00:00:00') {
173: // while technically this is not a default value of null,
174: // this seems to be closest in meaning.
175: return null;
176: } else {
177: try {
178: $dt = new DateTime($this->created_at);
179: } catch (Exception $x) {
180: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
181: }
182: }
183:
184: if ($format === null) {
185: // Because propel.useDateTimeClass is true, we return a DateTime object.
186: return $dt;
187: } elseif (strpos($format, '%') !== false) {
188: return strftime($format, $dt->format('U'));
189: } else {
190: return $dt->format($format);
191: }
192: }
193:
194: /**
195: * Get the [optionally formatted] temporal [updated_at] column value.
196: *
197: *
198: * @param string $format The date/time format string (either date()-style or strftime()-style).
199: * If format is null, then the raw DateTime object will be returned.
200: * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
201: * @throws PropelException - if unable to parse/validate the date/time value.
202: */
203: public function getUpdatedAt($format = 'Y-m-d H:i:s')
204: {
205: if ($this->updated_at === null) {
206: return null;
207: }
208:
209: if ($this->updated_at === '0000-00-00 00:00:00') {
210: // while technically this is not a default value of null,
211: // this seems to be closest in meaning.
212: return null;
213: } else {
214: try {
215: $dt = new DateTime($this->updated_at);
216: } catch (Exception $x) {
217: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
218: }
219: }
220:
221: if ($format === null) {
222: // Because propel.useDateTimeClass is true, we return a DateTime object.
223: return $dt;
224: } elseif (strpos($format, '%') !== false) {
225: return strftime($format, $dt->format('U'));
226: } else {
227: return $dt->format($format);
228: }
229: }
230:
231: /**
232: * Set the value of [id] column.
233: *
234: * @param int $v new value
235: * @return FeatureAv The current object (for fluent API support)
236: */
237: public function setId($v)
238: {
239: if ($v !== null) {
240: $v = (int) $v;
241: }
242:
243: if ($this->id !== $v) {
244: $this->id = $v;
245: $this->modifiedColumns[] = FeatureAvPeer::ID;
246: }
247:
248:
249: return $this;
250: } // setId()
251:
252: /**
253: * Set the value of [feature_id] column.
254: *
255: * @param int $v new value
256: * @return FeatureAv The current object (for fluent API support)
257: */
258: public function setFeatureId($v)
259: {
260: if ($v !== null) {
261: $v = (int) $v;
262: }
263:
264: if ($this->feature_id !== $v) {
265: $this->feature_id = $v;
266: $this->modifiedColumns[] = FeatureAvPeer::FEATURE_ID;
267: }
268:
269: if ($this->aFeature !== null && $this->aFeature->getId() !== $v) {
270: $this->aFeature = null;
271: }
272:
273:
274: return $this;
275: } // setFeatureId()
276:
277: /**
278: * Sets the value of [created_at] column to a normalized version of the date/time value specified.
279: *
280: * @param mixed $v string, integer (timestamp), or DateTime value.
281: * Empty strings are treated as null.
282: * @return FeatureAv The current object (for fluent API support)
283: */
284: public function setCreatedAt($v)
285: {
286: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
287: if ($this->created_at !== null || $dt !== null) {
288: $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
289: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
290: if ($currentDateAsString !== $newDateAsString) {
291: $this->created_at = $newDateAsString;
292: $this->modifiedColumns[] = FeatureAvPeer::CREATED_AT;
293: }
294: } // if either are not null
295:
296:
297: return $this;
298: } // setCreatedAt()
299:
300: /**
301: * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
302: *
303: * @param mixed $v string, integer (timestamp), or DateTime value.
304: * Empty strings are treated as null.
305: * @return FeatureAv The current object (for fluent API support)
306: */
307: public function setUpdatedAt($v)
308: {
309: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
310: if ($this->updated_at !== null || $dt !== null) {
311: $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
312: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
313: if ($currentDateAsString !== $newDateAsString) {
314: $this->updated_at = $newDateAsString;
315: $this->modifiedColumns[] = FeatureAvPeer::UPDATED_AT;
316: }
317: } // if either are not null
318:
319:
320: return $this;
321: } // setUpdatedAt()
322:
323: /**
324: * Indicates whether the columns in this object are only set to default values.
325: *
326: * This method can be used in conjunction with isModified() to indicate whether an object is both
327: * modified _and_ has some values set which are non-default.
328: *
329: * @return boolean Whether the columns in this object are only been set with default values.
330: */
331: public function hasOnlyDefaultValues()
332: {
333: // otherwise, everything was equal, so return true
334: return true;
335: } // hasOnlyDefaultValues()
336:
337: /**
338: * Hydrates (populates) the object variables with values from the database resultset.
339: *
340: * An offset (0-based "start column") is specified so that objects can be hydrated
341: * with a subset of the columns in the resultset rows. This is needed, for example,
342: * for results of JOIN queries where the resultset row includes columns from two or
343: * more tables.
344: *
345: * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
346: * @param int $startcol 0-based offset column which indicates which restultset column to start with.
347: * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
348: * @return int next starting column
349: * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
350: */
351: public function hydrate($row, $startcol = 0, $rehydrate = false)
352: {
353: try {
354:
355: $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
356: $this->feature_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
357: $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
358: $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
359: $this->resetModified();
360:
361: $this->setNew(false);
362:
363: if ($rehydrate) {
364: $this->ensureConsistency();
365: }
366:
367: return $startcol + 4; // 4 = FeatureAvPeer::NUM_HYDRATE_COLUMNS.
368:
369: } catch (Exception $e) {
370: throw new PropelException("Error populating FeatureAv object", $e);
371: }
372: }
373:
374: /**
375: * Checks and repairs the internal consistency of the object.
376: *
377: * This method is executed after an already-instantiated object is re-hydrated
378: * from the database. It exists to check any foreign keys to make sure that
379: * the objects related to the current object are correct based on foreign key.
380: *
381: * You can override this method in the stub class, but you should always invoke
382: * the base method from the overridden method (i.e. parent::ensureConsistency()),
383: * in case your model changes.
384: *
385: * @throws PropelException
386: */
387: public function ensureConsistency()
388: {
389:
390: if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) {
391: $this->aFeature = null;
392: }
393: } // ensureConsistency
394:
395: /**
396: * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
397: *
398: * This will only work if the object has been saved and has a valid primary key set.
399: *
400: * @param boolean $deep (optional) Whether to also de-associated any related objects.
401: * @param PropelPDO $con (optional) The PropelPDO connection to use.
402: * @return void
403: * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
404: */
405: public function reload($deep = false, PropelPDO $con = null)
406: {
407: if ($this->isDeleted()) {
408: throw new PropelException("Cannot reload a deleted object.");
409: }
410:
411: if ($this->isNew()) {
412: throw new PropelException("Cannot reload an unsaved object.");
413: }
414:
415: if ($con === null) {
416: $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
417: }
418:
419: // We don't need to alter the object instance pool; we're just modifying this instance
420: // already in the pool.
421:
422: $stmt = FeatureAvPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
423: $row = $stmt->fetch(PDO::FETCH_NUM);
424: $stmt->closeCursor();
425: if (!$row) {
426: throw new PropelException('Cannot find matching row in the database to reload object values.');
427: }
428: $this->hydrate($row, 0, true); // rehydrate
429:
430: if ($deep) { // also de-associate any related objects?
431:
432: $this->aFeature = null;
433: $this->collFeatureProds = null;
434:
435: $this->collFeatureAvI18ns = null;
436:
437: } // if (deep)
438: }
439:
440: /**
441: * Removes this object from datastore and sets delete attribute.
442: *
443: * @param PropelPDO $con
444: * @return void
445: * @throws PropelException
446: * @throws Exception
447: * @see BaseObject::setDeleted()
448: * @see BaseObject::isDeleted()
449: */
450: public function delete(PropelPDO $con = null)
451: {
452: if ($this->isDeleted()) {
453: throw new PropelException("This object has already been deleted.");
454: }
455:
456: if ($con === null) {
457: $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
458: }
459:
460: $con->beginTransaction();
461: try {
462: $deleteQuery = FeatureAvQuery::create()
463: ->filterByPrimaryKey($this->getPrimaryKey());
464: $ret = $this->preDelete($con);
465: if ($ret) {
466: $deleteQuery->delete($con);
467: $this->postDelete($con);
468: $con->commit();
469: $this->setDeleted(true);
470: } else {
471: $con->commit();
472: }
473: } catch (Exception $e) {
474: $con->rollBack();
475: throw $e;
476: }
477: }
478:
479: /**
480: * Persists this object to the database.
481: *
482: * If the object is new, it inserts it; otherwise an update is performed.
483: * All modified related objects will also be persisted in the doSave()
484: * method. This method wraps all precipitate database operations in a
485: * single transaction.
486: *
487: * @param PropelPDO $con
488: * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
489: * @throws PropelException
490: * @throws Exception
491: * @see doSave()
492: */
493: public function save(PropelPDO $con = null)
494: {
495: if ($this->isDeleted()) {
496: throw new PropelException("You cannot save an object that has been deleted.");
497: }
498:
499: if ($con === null) {
500: $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
501: }
502:
503: $con->beginTransaction();
504: $isInsert = $this->isNew();
505: try {
506: $ret = $this->preSave($con);
507: if ($isInsert) {
508: $ret = $ret && $this->preInsert($con);
509: // timestampable behavior
510: if (!$this->isColumnModified(FeatureAvPeer::CREATED_AT)) {
511: $this->setCreatedAt(time());
512: }
513: if (!$this->isColumnModified(FeatureAvPeer::UPDATED_AT)) {
514: $this->setUpdatedAt(time());
515: }
516: } else {
517: $ret = $ret && $this->preUpdate($con);
518: // timestampable behavior
519: if ($this->isModified() && !$this->isColumnModified(FeatureAvPeer::UPDATED_AT)) {
520: $this->setUpdatedAt(time());
521: }
522: }
523: if ($ret) {
524: $affectedRows = $this->doSave($con);
525: if ($isInsert) {
526: $this->postInsert($con);
527: } else {
528: $this->postUpdate($con);
529: }
530: $this->postSave($con);
531: FeatureAvPeer::addInstanceToPool($this);
532: } else {
533: $affectedRows = 0;
534: }
535: $con->commit();
536:
537: return $affectedRows;
538: } catch (Exception $e) {
539: $con->rollBack();
540: throw $e;
541: }
542: }
543:
544: /**
545: * Performs the work of inserting or updating the row in the database.
546: *
547: * If the object is new, it inserts it; otherwise an update is performed.
548: * All related objects are also updated in this method.
549: *
550: * @param PropelPDO $con
551: * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
552: * @throws PropelException
553: * @see save()
554: */
555: protected function doSave(PropelPDO $con)
556: {
557: $affectedRows = 0; // initialize var to track total num of affected rows
558: if (!$this->alreadyInSave) {
559: $this->alreadyInSave = true;
560:
561: // We call the save method on the following object(s) if they
562: // were passed to this object by their coresponding set
563: // method. This object relates to these object(s) by a
564: // foreign key reference.
565:
566: if ($this->aFeature !== null) {
567: if ($this->aFeature->isModified() || $this->aFeature->isNew()) {
568: $affectedRows += $this->aFeature->save($con);
569: }
570: $this->setFeature($this->aFeature);
571: }
572:
573: if ($this->isNew() || $this->isModified()) {
574: // persist changes
575: if ($this->isNew()) {
576: $this->doInsert($con);
577: } else {
578: $this->doUpdate($con);
579: }
580: $affectedRows += 1;
581: $this->resetModified();
582: }
583:
584: if ($this->featureProdsScheduledForDeletion !== null) {
585: if (!$this->featureProdsScheduledForDeletion->isEmpty()) {
586: foreach ($this->featureProdsScheduledForDeletion as $featureProd) {
587: // need to save related object because we set the relation to null
588: $featureProd->save($con);
589: }
590: $this->featureProdsScheduledForDeletion = null;
591: }
592: }
593:
594: if ($this->collFeatureProds !== null) {
595: foreach ($this->collFeatureProds as $referrerFK) {
596: if (!$referrerFK->isDeleted()) {
597: $affectedRows += $referrerFK->save($con);
598: }
599: }
600: }
601:
602: if ($this->featureAvI18nsScheduledForDeletion !== null) {
603: if (!$this->featureAvI18nsScheduledForDeletion->isEmpty()) {
604: FeatureAvI18nQuery::create()
605: ->filterByPrimaryKeys($this->featureAvI18nsScheduledForDeletion->getPrimaryKeys(false))
606: ->delete($con);
607: $this->featureAvI18nsScheduledForDeletion = null;
608: }
609: }
610:
611: if ($this->collFeatureAvI18ns !== null) {
612: foreach ($this->collFeatureAvI18ns as $referrerFK) {
613: if (!$referrerFK->isDeleted()) {
614: $affectedRows += $referrerFK->save($con);
615: }
616: }
617: }
618:
619: $this->alreadyInSave = false;
620:
621: }
622:
623: return $affectedRows;
624: } // doSave()
625:
626: /**
627: * Insert the row in the database.
628: *
629: * @param PropelPDO $con
630: *
631: * @throws PropelException
632: * @see doSave()
633: */
634: protected function doInsert(PropelPDO $con)
635: {
636: $modifiedColumns = array();
637: $index = 0;
638:
639: $this->modifiedColumns[] = FeatureAvPeer::ID;
640: if (null !== $this->id) {
641: throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureAvPeer::ID . ')');
642: }
643:
644: // check the columns in natural order for more readable SQL queries
645: if ($this->isColumnModified(FeatureAvPeer::ID)) {
646: $modifiedColumns[':p' . $index++] = '`ID`';
647: }
648: if ($this->isColumnModified(FeatureAvPeer::FEATURE_ID)) {
649: $modifiedColumns[':p' . $index++] = '`FEATURE_ID`';
650: }
651: if ($this->isColumnModified(FeatureAvPeer::CREATED_AT)) {
652: $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
653: }
654: if ($this->isColumnModified(FeatureAvPeer::UPDATED_AT)) {
655: $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
656: }
657:
658: $sql = sprintf(
659: 'INSERT INTO `feature_av` (%s) VALUES (%s)',
660: implode(', ', $modifiedColumns),
661: implode(', ', array_keys($modifiedColumns))
662: );
663:
664: try {
665: $stmt = $con->prepare($sql);
666: foreach ($modifiedColumns as $identifier => $columnName) {
667: switch ($columnName) {
668: case '`ID`':
669: $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
670: break;
671: case '`FEATURE_ID`':
672: $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT);
673: break;
674: case '`CREATED_AT`':
675: $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
676: break;
677: case '`UPDATED_AT`':
678: $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
679: break;
680: }
681: }
682: $stmt->execute();
683: } catch (Exception $e) {
684: Propel::log($e->getMessage(), Propel::LOG_ERR);
685: throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
686: }
687:
688: try {
689: $pk = $con->lastInsertId();
690: } catch (Exception $e) {
691: throw new PropelException('Unable to get autoincrement id.', $e);
692: }
693: $this->setId($pk);
694:
695: $this->setNew(false);
696: }
697:
698: /**
699: * Update the row in the database.
700: *
701: * @param PropelPDO $con
702: *
703: * @see doSave()
704: */
705: protected function doUpdate(PropelPDO $con)
706: {
707: $selectCriteria = $this->buildPkeyCriteria();
708: $valuesCriteria = $this->buildCriteria();
709: BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
710: }
711:
712: /**
713: * Array of ValidationFailed objects.
714: * @var array ValidationFailed[]
715: */
716: protected $validationFailures = array();
717:
718: /**
719: * Gets any ValidationFailed objects that resulted from last call to validate().
720: *
721: *
722: * @return array ValidationFailed[]
723: * @see validate()
724: */
725: public function getValidationFailures()
726: {
727: return $this->validationFailures;
728: }
729:
730: /**
731: * Validates the objects modified field values and all objects related to this table.
732: *
733: * If $columns is either a column name or an array of column names
734: * only those columns are validated.
735: *
736: * @param mixed $columns Column name or an array of column names.
737: * @return boolean Whether all columns pass validation.
738: * @see doValidate()
739: * @see getValidationFailures()
740: */
741: public function validate($columns = null)
742: {
743: $res = $this->doValidate($columns);
744: if ($res === true) {
745: $this->validationFailures = array();
746:
747: return true;
748: } else {
749: $this->validationFailures = $res;
750:
751: return false;
752: }
753: }
754:
755: /**
756: * This function performs the validation work for complex object models.
757: *
758: * In addition to checking the current object, all related objects will
759: * also be validated. If all pass then <code>true</code> is returned; otherwise
760: * an aggreagated array of ValidationFailed objects will be returned.
761: *
762: * @param array $columns Array of column names to validate.
763: * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
764: */
765: protected function doValidate($columns = null)
766: {
767: if (!$this->alreadyInValidation) {
768: $this->alreadyInValidation = true;
769: $retval = null;
770:
771: $failureMap = array();
772:
773:
774: // We call the validate method on the following object(s) if they
775: // were passed to this object by their coresponding set
776: // method. This object relates to these object(s) by a
777: // foreign key reference.
778:
779: if ($this->aFeature !== null) {
780: if (!$this->aFeature->validate($columns)) {
781: $failureMap = array_merge($failureMap, $this->aFeature->getValidationFailures());
782: }
783: }
784:
785:
786: if (($retval = FeatureAvPeer::doValidate($this, $columns)) !== true) {
787: $failureMap = array_merge($failureMap, $retval);
788: }
789:
790:
791: if ($this->collFeatureProds !== null) {
792: foreach ($this->collFeatureProds as $referrerFK) {
793: if (!$referrerFK->validate($columns)) {
794: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
795: }
796: }
797: }
798:
799: if ($this->collFeatureAvI18ns !== null) {
800: foreach ($this->collFeatureAvI18ns as $referrerFK) {
801: if (!$referrerFK->validate($columns)) {
802: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
803: }
804: }
805: }
806:
807:
808: $this->alreadyInValidation = false;
809: }
810:
811: return (!empty($failureMap) ? $failureMap : true);
812: }
813:
814: /**
815: * Retrieves a field from the object by name passed in as a string.
816: *
817: * @param string $name name
818: * @param string $type The type of fieldname the $name is of:
819: * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
820: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
821: * Defaults to BasePeer::TYPE_PHPNAME
822: * @return mixed Value of field.
823: */
824: public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
825: {
826: $pos = FeatureAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
827: $field = $this->getByPosition($pos);
828:
829: return $field;
830: }
831:
832: /**
833: * Retrieves a field from the object by Position as specified in the xml schema.
834: * Zero-based.
835: *
836: * @param int $pos position in xml schema
837: * @return mixed Value of field at $pos
838: */
839: public function getByPosition($pos)
840: {
841: switch ($pos) {
842: case 0:
843: return $this->getId();
844: break;
845: case 1:
846: return $this->getFeatureId();
847: break;
848: case 2:
849: return $this->getCreatedAt();
850: break;
851: case 3:
852: return $this->getUpdatedAt();
853: break;
854: default:
855: return null;
856: break;
857: } // switch()
858: }
859:
860: /**
861: * Exports the object as an array.
862: *
863: * You can specify the key type of the array by passing one of the class
864: * type constants.
865: *
866: * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
867: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
868: * Defaults to BasePeer::TYPE_PHPNAME.
869: * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
870: * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
871: * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
872: *
873: * @return array an associative array containing the field names (as keys) and field values
874: */
875: public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
876: {
877: if (isset($alreadyDumpedObjects['FeatureAv'][$this->getPrimaryKey()])) {
878: return '*RECURSION*';
879: }
880: $alreadyDumpedObjects['FeatureAv'][$this->getPrimaryKey()] = true;
881: $keys = FeatureAvPeer::getFieldNames($keyType);
882: $result = array(
883: $keys[0] => $this->getId(),
884: $keys[1] => $this->getFeatureId(),
885: $keys[2] => $this->getCreatedAt(),
886: $keys[3] => $this->getUpdatedAt(),
887: );
888: if ($includeForeignObjects) {
889: if (null !== $this->aFeature) {
890: $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
891: }
892: if (null !== $this->collFeatureProds) {
893: $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
894: }
895: if (null !== $this->collFeatureAvI18ns) {
896: $result['FeatureAvI18ns'] = $this->collFeatureAvI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
897: }
898: }
899:
900: return $result;
901: }
902:
903: /**
904: * Sets a field from the object by name passed in as a string.
905: *
906: * @param string $name peer name
907: * @param mixed $value field value
908: * @param string $type The type of fieldname the $name is of:
909: * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
910: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
911: * Defaults to BasePeer::TYPE_PHPNAME
912: * @return void
913: */
914: public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
915: {
916: $pos = FeatureAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
917:
918: $this->setByPosition($pos, $value);
919: }
920:
921: /**
922: * Sets a field from the object by Position as specified in the xml schema.
923: * Zero-based.
924: *
925: * @param int $pos position in xml schema
926: * @param mixed $value field value
927: * @return void
928: */
929: public function setByPosition($pos, $value)
930: {
931: switch ($pos) {
932: case 0:
933: $this->setId($value);
934: break;
935: case 1:
936: $this->setFeatureId($value);
937: break;
938: case 2:
939: $this->setCreatedAt($value);
940: break;
941: case 3:
942: $this->setUpdatedAt($value);
943: break;
944: } // switch()
945: }
946:
947: /**
948: * Populates the object using an array.
949: *
950: * This is particularly useful when populating an object from one of the
951: * request arrays (e.g. $_POST). This method goes through the column
952: * names, checking to see whether a matching key exists in populated
953: * array. If so the setByName() method is called for that column.
954: *
955: * You can specify the key type of the array by additionally passing one
956: * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
957: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
958: * The default key type is the column's BasePeer::TYPE_PHPNAME
959: *
960: * @param array $arr An array to populate the object from.
961: * @param string $keyType The type of keys the array uses.
962: * @return void
963: */
964: public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
965: {
966: $keys = FeatureAvPeer::getFieldNames($keyType);
967:
968: if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
969: if (array_key_exists($keys[1], $arr)) $this->setFeatureId($arr[$keys[1]]);
970: if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
971: if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
972: }
973:
974: /**
975: * Build a Criteria object containing the values of all modified columns in this object.
976: *
977: * @return Criteria The Criteria object containing all modified values.
978: */
979: public function buildCriteria()
980: {
981: $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME);
982:
983: if ($this->isColumnModified(FeatureAvPeer::ID)) $criteria->add(FeatureAvPeer::ID, $this->id);
984: if ($this->isColumnModified(FeatureAvPeer::FEATURE_ID)) $criteria->add(FeatureAvPeer::FEATURE_ID, $this->feature_id);
985: if ($this->isColumnModified(FeatureAvPeer::CREATED_AT)) $criteria->add(FeatureAvPeer::CREATED_AT, $this->created_at);
986: if ($this->isColumnModified(FeatureAvPeer::UPDATED_AT)) $criteria->add(FeatureAvPeer::UPDATED_AT, $this->updated_at);
987:
988: return $criteria;
989: }
990:
991: /**
992: * Builds a Criteria object containing the primary key for this object.
993: *
994: * Unlike buildCriteria() this method includes the primary key values regardless
995: * of whether or not they have been modified.
996: *
997: * @return Criteria The Criteria object containing value(s) for primary key(s).
998: */
999: public function buildPkeyCriteria()
1000: {
1001: $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME);
1002: $criteria->add(FeatureAvPeer::ID, $this->id);
1003:
1004: return $criteria;
1005: }
1006:
1007: /**
1008: * Returns the primary key for this object (row).
1009: * @return int
1010: */
1011: public function getPrimaryKey()
1012: {
1013: return $this->getId();
1014: }
1015:
1016: /**
1017: * Generic method to set the primary key (id column).
1018: *
1019: * @param int $key Primary key.
1020: * @return void
1021: */
1022: public function setPrimaryKey($key)
1023: {
1024: $this->setId($key);
1025: }
1026:
1027: /**
1028: * Returns true if the primary key for this object is null.
1029: * @return boolean
1030: */
1031: public function isPrimaryKeyNull()
1032: {
1033:
1034: return null === $this->getId();
1035: }
1036:
1037: /**
1038: * Sets contents of passed object to values from current object.
1039: *
1040: * If desired, this method can also make copies of all associated (fkey referrers)
1041: * objects.
1042: *
1043: * @param object $copyObj An object of FeatureAv (or compatible) type.
1044: * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1045: * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1046: * @throws PropelException
1047: */
1048: public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1049: {
1050: $copyObj->setFeatureId($this->getFeatureId());
1051: $copyObj->setCreatedAt($this->getCreatedAt());
1052: $copyObj->setUpdatedAt($this->getUpdatedAt());
1053:
1054: if ($deepCopy && !$this->startCopy) {
1055: // important: temporarily setNew(false) because this affects the behavior of
1056: // the getter/setter methods for fkey referrer objects.
1057: $copyObj->setNew(false);
1058: // store object hash to prevent cycle
1059: $this->startCopy = true;
1060:
1061: foreach ($this->getFeatureProds() as $relObj) {
1062: if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
1063: $copyObj->addFeatureProd($relObj->copy($deepCopy));
1064: }
1065: }
1066:
1067: foreach ($this->getFeatureAvI18ns() as $relObj) {
1068: if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
1069: $copyObj->addFeatureAvI18n($relObj->copy($deepCopy));
1070: }
1071: }
1072:
1073: //unflag object copy
1074: $this->startCopy = false;
1075: } // if ($deepCopy)
1076:
1077: if ($makeNew) {
1078: $copyObj->setNew(true);
1079: $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
1080: }
1081: }
1082:
1083: /**
1084: * Makes a copy of this object that will be inserted as a new row in table when saved.
1085: * It creates a new object filling in the simple attributes, but skipping any primary
1086: * keys that are defined for the table.
1087: *
1088: * If desired, this method can also make copies of all associated (fkey referrers)
1089: * objects.
1090: *
1091: * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1092: * @return FeatureAv Clone of current object.
1093: * @throws PropelException
1094: */
1095: public function copy($deepCopy = false)
1096: {
1097: // we use get_class(), because this might be a subclass
1098: $clazz = get_class($this);
1099: $copyObj = new $clazz();
1100: $this->copyInto($copyObj, $deepCopy);
1101:
1102: return $copyObj;
1103: }
1104:
1105: /**
1106: * Returns a peer instance associated with this om.
1107: *
1108: * Since Peer classes are not to have any instance attributes, this method returns the
1109: * same instance for all member of this class. The method could therefore
1110: * be static, but this would prevent one from overriding the behavior.
1111: *
1112: * @return FeatureAvPeer
1113: */
1114: public function getPeer()
1115: {
1116: if (self::$peer === null) {
1117: self::$peer = new FeatureAvPeer();
1118: }
1119:
1120: return self::$peer;
1121: }
1122:
1123: /**
1124: * Declares an association between this object and a Feature object.
1125: *
1126: * @param Feature $v
1127: * @return FeatureAv The current object (for fluent API support)
1128: * @throws PropelException
1129: */
1130: public function setFeature(Feature $v = null)
1131: {
1132: if ($v === null) {
1133: $this->setFeatureId(NULL);
1134: } else {
1135: $this->setFeatureId($v->getId());
1136: }
1137:
1138: $this->aFeature = $v;
1139:
1140: // Add binding for other direction of this n:n relationship.
1141: // If this object has already been added to the Feature object, it will not be re-added.
1142: if ($v !== null) {
1143: $v->addFeatureAv($this);
1144: }
1145:
1146:
1147: return $this;
1148: }
1149:
1150:
1151: /**
1152: * Get the associated Feature object
1153: *
1154: * @param PropelPDO $con Optional Connection object.
1155: * @return Feature The associated Feature object.
1156: * @throws PropelException
1157: */
1158: public function getFeature(PropelPDO $con = null)
1159: {
1160: if ($this->aFeature === null && ($this->feature_id !== null)) {
1161: $this->aFeature = FeatureQuery::create()->findPk($this->feature_id, $con);
1162: /* The following can be used additionally to
1163: guarantee the related object contains a reference
1164: to this object. This level of coupling may, however, be
1165: undesirable since it could result in an only partially populated collection
1166: in the referenced object.
1167: $this->aFeature->addFeatureAvs($this);
1168: */
1169: }
1170:
1171: return $this->aFeature;
1172: }
1173:
1174:
1175: /**
1176: * Initializes a collection based on the name of a relation.
1177: * Avoids crafting an 'init[$relationName]s' method name
1178: * that wouldn't work when StandardEnglishPluralizer is used.
1179: *
1180: * @param string $relationName The name of the relation to initialize
1181: * @return void
1182: */
1183: public function initRelation($relationName)
1184: {
1185: if ('FeatureProd' == $relationName) {
1186: $this->initFeatureProds();
1187: }
1188: if ('FeatureAvI18n' == $relationName) {
1189: $this->initFeatureAvI18ns();
1190: }
1191: }
1192:
1193: /**
1194: * Clears out the collFeatureProds collection
1195: *
1196: * This does not modify the database; however, it will remove any associated objects, causing
1197: * them to be refetched by subsequent calls to accessor method.
1198: *
1199: * @return void
1200: * @see addFeatureProds()
1201: */
1202: public function clearFeatureProds()
1203: {
1204: $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized
1205: $this->collFeatureProdsPartial = null;
1206: }
1207:
1208: /**
1209: * reset is the collFeatureProds collection loaded partially
1210: *
1211: * @return void
1212: */
1213: public function resetPartialFeatureProds($v = true)
1214: {
1215: $this->collFeatureProdsPartial = $v;
1216: }
1217:
1218: /**
1219: * Initializes the collFeatureProds collection.
1220: *
1221: * By default this just sets the collFeatureProds collection to an empty array (like clearcollFeatureProds());
1222: * however, you may wish to override this method in your stub class to provide setting appropriate
1223: * to your application -- for example, setting the initial array to the values stored in database.
1224: *
1225: * @param boolean $overrideExisting If set to true, the method call initializes
1226: * the collection even if it is not empty
1227: *
1228: * @return void
1229: */
1230: public function initFeatureProds($overrideExisting = true)
1231: {
1232: if (null !== $this->collFeatureProds && !$overrideExisting) {
1233: return;
1234: }
1235: $this->collFeatureProds = new PropelObjectCollection();
1236: $this->collFeatureProds->setModel('FeatureProd');
1237: }
1238:
1239: /**
1240: * Gets an array of FeatureProd objects which contain a foreign key that references this object.
1241: *
1242: * If the $criteria is not null, it is used to always fetch the results from the database.
1243: * Otherwise the results are fetched from the database the first time, then cached.
1244: * Next time the same method is called without $criteria, the cached collection is returned.
1245: * If this FeatureAv is new, it will return
1246: * an empty collection or the current collection; the criteria is ignored on a new object.
1247: *
1248: * @param Criteria $criteria optional Criteria object to narrow the query
1249: * @param PropelPDO $con optional connection object
1250: * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects
1251: * @throws PropelException
1252: */
1253: public function getFeatureProds($criteria = null, PropelPDO $con = null)
1254: {
1255: $partial = $this->collFeatureProdsPartial && !$this->isNew();
1256: if (null === $this->collFeatureProds || null !== $criteria || $partial) {
1257: if ($this->isNew() && null === $this->collFeatureProds) {
1258: // return empty collection
1259: $this->initFeatureProds();
1260: } else {
1261: $collFeatureProds = FeatureProdQuery::create(null, $criteria)
1262: ->filterByFeatureAv($this)
1263: ->find($con);
1264: if (null !== $criteria) {
1265: if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) {
1266: $this->initFeatureProds(false);
1267:
1268: foreach($collFeatureProds as $obj) {
1269: if (false == $this->collFeatureProds->contains($obj)) {
1270: $this->collFeatureProds->append($obj);
1271: }
1272: }
1273:
1274: $this->collFeatureProdsPartial = true;
1275: }
1276:
1277: return $collFeatureProds;
1278: }
1279:
1280: if($partial && $this->collFeatureProds) {
1281: foreach($this->collFeatureProds as $obj) {
1282: if($obj->isNew()) {
1283: $collFeatureProds[] = $obj;
1284: }
1285: }
1286: }
1287:
1288: $this->collFeatureProds = $collFeatureProds;
1289: $this->collFeatureProdsPartial = false;
1290: }
1291: }
1292:
1293: return $this->collFeatureProds;
1294: }
1295:
1296: /**
1297: * Sets a collection of FeatureProd objects related by a one-to-many relationship
1298: * to the current object.
1299: * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1300: * and new objects from the given Propel collection.
1301: *
1302: * @param PropelCollection $featureProds A Propel collection.
1303: * @param PropelPDO $con Optional connection object
1304: */
1305: public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null)
1306: {
1307: $this->featureProdsScheduledForDeletion = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds);
1308:
1309: foreach ($this->featureProdsScheduledForDeletion as $featureProdRemoved) {
1310: $featureProdRemoved->setFeatureAv(null);
1311: }
1312:
1313: $this->collFeatureProds = null;
1314: foreach ($featureProds as $featureProd) {
1315: $this->addFeatureProd($featureProd);
1316: }
1317:
1318: $this->collFeatureProds = $featureProds;
1319: $this->collFeatureProdsPartial = false;
1320: }
1321:
1322: /**
1323: * Returns the number of related FeatureProd objects.
1324: *
1325: * @param Criteria $criteria
1326: * @param boolean $distinct
1327: * @param PropelPDO $con
1328: * @return int Count of related FeatureProd objects.
1329: * @throws PropelException
1330: */
1331: public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1332: {
1333: $partial = $this->collFeatureProdsPartial && !$this->isNew();
1334: if (null === $this->collFeatureProds || null !== $criteria || $partial) {
1335: if ($this->isNew() && null === $this->collFeatureProds) {
1336: return 0;
1337: } else {
1338: if($partial && !$criteria) {
1339: return count($this->getFeatureProds());
1340: }
1341: $query = FeatureProdQuery::create(null, $criteria);
1342: if ($distinct) {
1343: $query->distinct();
1344: }
1345:
1346: return $query
1347: ->filterByFeatureAv($this)
1348: ->count($con);
1349: }
1350: } else {
1351: return count($this->collFeatureProds);
1352: }
1353: }
1354:
1355: /**
1356: * Method called to associate a FeatureProd object to this object
1357: * through the FeatureProd foreign key attribute.
1358: *
1359: * @param FeatureProd $l FeatureProd
1360: * @return FeatureAv The current object (for fluent API support)
1361: */
1362: public function addFeatureProd(FeatureProd $l)
1363: {
1364: if ($this->collFeatureProds === null) {
1365: $this->initFeatureProds();
1366: $this->collFeatureProdsPartial = true;
1367: }
1368: if (!$this->collFeatureProds->contains($l)) { // only add it if the **same** object is not already associated
1369: $this->doAddFeatureProd($l);
1370: }
1371:
1372: return $this;
1373: }
1374:
1375: /**
1376: * @param FeatureProd $featureProd The featureProd object to add.
1377: */
1378: protected function doAddFeatureProd($featureProd)
1379: {
1380: $this->collFeatureProds[]= $featureProd;
1381: $featureProd->setFeatureAv($this);
1382: }
1383:
1384: /**
1385: * @param FeatureProd $featureProd The featureProd object to remove.
1386: */
1387: public function removeFeatureProd($featureProd)
1388: {
1389: if ($this->getFeatureProds()->contains($featureProd)) {
1390: $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd));
1391: if (null === $this->featureProdsScheduledForDeletion) {
1392: $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds;
1393: $this->featureProdsScheduledForDeletion->clear();
1394: }
1395: $this->featureProdsScheduledForDeletion[]= $featureProd;
1396: $featureProd->setFeatureAv(null);
1397: }
1398: }
1399:
1400:
1401: /**
1402: * If this collection has already been initialized with
1403: * an identical criteria, it returns the collection.
1404: * Otherwise if this FeatureAv is new, it will return
1405: * an empty collection; or if this FeatureAv has previously
1406: * been saved, it will retrieve related FeatureProds from storage.
1407: *
1408: * This method is protected by default in order to keep the public
1409: * api reasonable. You can provide public methods for those you
1410: * actually need in FeatureAv.
1411: *
1412: * @param Criteria $criteria optional Criteria object to narrow the query
1413: * @param PropelPDO $con optional connection object
1414: * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1415: * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects
1416: */
1417: public function getFeatureProdsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1418: {
1419: $query = FeatureProdQuery::create(null, $criteria);
1420: $query->joinWith('Product', $join_behavior);
1421:
1422: return $this->getFeatureProds($query, $con);
1423: }
1424:
1425:
1426: /**
1427: * If this collection has already been initialized with
1428: * an identical criteria, it returns the collection.
1429: * Otherwise if this FeatureAv is new, it will return
1430: * an empty collection; or if this FeatureAv has previously
1431: * been saved, it will retrieve related FeatureProds from storage.
1432: *
1433: * This method is protected by default in order to keep the public
1434: * api reasonable. You can provide public methods for those you
1435: * actually need in FeatureAv.
1436: *
1437: * @param Criteria $criteria optional Criteria object to narrow the query
1438: * @param PropelPDO $con optional connection object
1439: * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1440: * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects
1441: */
1442: public function getFeatureProdsJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1443: {
1444: $query = FeatureProdQuery::create(null, $criteria);
1445: $query->joinWith('Feature', $join_behavior);
1446:
1447: return $this->getFeatureProds($query, $con);
1448: }
1449:
1450: /**
1451: * Clears out the collFeatureAvI18ns collection
1452: *
1453: * This does not modify the database; however, it will remove any associated objects, causing
1454: * them to be refetched by subsequent calls to accessor method.
1455: *
1456: * @return void
1457: * @see addFeatureAvI18ns()
1458: */
1459: public function clearFeatureAvI18ns()
1460: {
1461: $this->collFeatureAvI18ns = null; // important to set this to null since that means it is uninitialized
1462: $this->collFeatureAvI18nsPartial = null;
1463: }
1464:
1465: /**
1466: * reset is the collFeatureAvI18ns collection loaded partially
1467: *
1468: * @return void
1469: */
1470: public function resetPartialFeatureAvI18ns($v = true)
1471: {
1472: $this->collFeatureAvI18nsPartial = $v;
1473: }
1474:
1475: /**
1476: * Initializes the collFeatureAvI18ns collection.
1477: *
1478: * By default this just sets the collFeatureAvI18ns collection to an empty array (like clearcollFeatureAvI18ns());
1479: * however, you may wish to override this method in your stub class to provide setting appropriate
1480: * to your application -- for example, setting the initial array to the values stored in database.
1481: *
1482: * @param boolean $overrideExisting If set to true, the method call initializes
1483: * the collection even if it is not empty
1484: *
1485: * @return void
1486: */
1487: public function initFeatureAvI18ns($overrideExisting = true)
1488: {
1489: if (null !== $this->collFeatureAvI18ns && !$overrideExisting) {
1490: return;
1491: }
1492: $this->collFeatureAvI18ns = new PropelObjectCollection();
1493: $this->collFeatureAvI18ns->setModel('FeatureAvI18n');
1494: }
1495:
1496: /**
1497: * Gets an array of FeatureAvI18n objects which contain a foreign key that references this object.
1498: *
1499: * If the $criteria is not null, it is used to always fetch the results from the database.
1500: * Otherwise the results are fetched from the database the first time, then cached.
1501: * Next time the same method is called without $criteria, the cached collection is returned.
1502: * If this FeatureAv is new, it will return
1503: * an empty collection or the current collection; the criteria is ignored on a new object.
1504: *
1505: * @param Criteria $criteria optional Criteria object to narrow the query
1506: * @param PropelPDO $con optional connection object
1507: * @return PropelObjectCollection|FeatureAvI18n[] List of FeatureAvI18n objects
1508: * @throws PropelException
1509: */
1510: public function getFeatureAvI18ns($criteria = null, PropelPDO $con = null)
1511: {
1512: $partial = $this->collFeatureAvI18nsPartial && !$this->isNew();
1513: if (null === $this->collFeatureAvI18ns || null !== $criteria || $partial) {
1514: if ($this->isNew() && null === $this->collFeatureAvI18ns) {
1515: // return empty collection
1516: $this->initFeatureAvI18ns();
1517: } else {
1518: $collFeatureAvI18ns = FeatureAvI18nQuery::create(null, $criteria)
1519: ->filterByFeatureAv($this)
1520: ->find($con);
1521: if (null !== $criteria) {
1522: if (false !== $this->collFeatureAvI18nsPartial && count($collFeatureAvI18ns)) {
1523: $this->initFeatureAvI18ns(false);
1524:
1525: foreach($collFeatureAvI18ns as $obj) {
1526: if (false == $this->collFeatureAvI18ns->contains($obj)) {
1527: $this->collFeatureAvI18ns->append($obj);
1528: }
1529: }
1530:
1531: $this->collFeatureAvI18nsPartial = true;
1532: }
1533:
1534: return $collFeatureAvI18ns;
1535: }
1536:
1537: if($partial && $this->collFeatureAvI18ns) {
1538: foreach($this->collFeatureAvI18ns as $obj) {
1539: if($obj->isNew()) {
1540: $collFeatureAvI18ns[] = $obj;
1541: }
1542: }
1543: }
1544:
1545: $this->collFeatureAvI18ns = $collFeatureAvI18ns;
1546: $this->collFeatureAvI18nsPartial = false;
1547: }
1548: }
1549:
1550: return $this->collFeatureAvI18ns;
1551: }
1552:
1553: /**
1554: * Sets a collection of FeatureAvI18n objects related by a one-to-many relationship
1555: * to the current object.
1556: * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1557: * and new objects from the given Propel collection.
1558: *
1559: * @param PropelCollection $featureAvI18ns A Propel collection.
1560: * @param PropelPDO $con Optional connection object
1561: */
1562: public function setFeatureAvI18ns(PropelCollection $featureAvI18ns, PropelPDO $con = null)
1563: {
1564: $this->featureAvI18nsScheduledForDeletion = $this->getFeatureAvI18ns(new Criteria(), $con)->diff($featureAvI18ns);
1565:
1566: foreach ($this->featureAvI18nsScheduledForDeletion as $featureAvI18nRemoved) {
1567: $featureAvI18nRemoved->setFeatureAv(null);
1568: }
1569:
1570: $this->collFeatureAvI18ns = null;
1571: foreach ($featureAvI18ns as $featureAvI18n) {
1572: $this->addFeatureAvI18n($featureAvI18n);
1573: }
1574:
1575: $this->collFeatureAvI18ns = $featureAvI18ns;
1576: $this->collFeatureAvI18nsPartial = false;
1577: }
1578:
1579: /**
1580: * Returns the number of related FeatureAvI18n objects.
1581: *
1582: * @param Criteria $criteria
1583: * @param boolean $distinct
1584: * @param PropelPDO $con
1585: * @return int Count of related FeatureAvI18n objects.
1586: * @throws PropelException
1587: */
1588: public function countFeatureAvI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1589: {
1590: $partial = $this->collFeatureAvI18nsPartial && !$this->isNew();
1591: if (null === $this->collFeatureAvI18ns || null !== $criteria || $partial) {
1592: if ($this->isNew() && null === $this->collFeatureAvI18ns) {
1593: return 0;
1594: } else {
1595: if($partial && !$criteria) {
1596: return count($this->getFeatureAvI18ns());
1597: }
1598: $query = FeatureAvI18nQuery::create(null, $criteria);
1599: if ($distinct) {
1600: $query->distinct();
1601: }
1602:
1603: return $query
1604: ->filterByFeatureAv($this)
1605: ->count($con);
1606: }
1607: } else {
1608: return count($this->collFeatureAvI18ns);
1609: }
1610: }
1611:
1612: /**
1613: * Method called to associate a FeatureAvI18n object to this object
1614: * through the FeatureAvI18n foreign key attribute.
1615: *
1616: * @param FeatureAvI18n $l FeatureAvI18n
1617: * @return FeatureAv The current object (for fluent API support)
1618: */
1619: public function addFeatureAvI18n(FeatureAvI18n $l)
1620: {
1621: if ($l && $locale = $l->getLocale()) {
1622: $this->setLocale($locale);
1623: $this->currentTranslations[$locale] = $l;
1624: }
1625: if ($this->collFeatureAvI18ns === null) {
1626: $this->initFeatureAvI18ns();
1627: $this->collFeatureAvI18nsPartial = true;
1628: }
1629: if (!$this->collFeatureAvI18ns->contains($l)) { // only add it if the **same** object is not already associated
1630: $this->doAddFeatureAvI18n($l);
1631: }
1632:
1633: return $this;
1634: }
1635:
1636: /**
1637: * @param FeatureAvI18n $featureAvI18n The featureAvI18n object to add.
1638: */
1639: protected function doAddFeatureAvI18n($featureAvI18n)
1640: {
1641: $this->collFeatureAvI18ns[]= $featureAvI18n;
1642: $featureAvI18n->setFeatureAv($this);
1643: }
1644:
1645: /**
1646: * @param FeatureAvI18n $featureAvI18n The featureAvI18n object to remove.
1647: */
1648: public function removeFeatureAvI18n($featureAvI18n)
1649: {
1650: if ($this->getFeatureAvI18ns()->contains($featureAvI18n)) {
1651: $this->collFeatureAvI18ns->remove($this->collFeatureAvI18ns->search($featureAvI18n));
1652: if (null === $this->featureAvI18nsScheduledForDeletion) {
1653: $this->featureAvI18nsScheduledForDeletion = clone $this->collFeatureAvI18ns;
1654: $this->featureAvI18nsScheduledForDeletion->clear();
1655: }
1656: $this->featureAvI18nsScheduledForDeletion[]= $featureAvI18n;
1657: $featureAvI18n->setFeatureAv(null);
1658: }
1659: }
1660:
1661: /**
1662: * Clears the current object and sets all attributes to their default values
1663: */
1664: public function clear()
1665: {
1666: $this->id = null;
1667: $this->feature_id = null;
1668: $this->created_at = null;
1669: $this->updated_at = null;
1670: $this->alreadyInSave = false;
1671: $this->alreadyInValidation = false;
1672: $this->clearAllReferences();
1673: $this->resetModified();
1674: $this->setNew(true);
1675: $this->setDeleted(false);
1676: }
1677:
1678: /**
1679: * Resets all references to other model objects or collections of model objects.
1680: *
1681: * This method is a user-space workaround for PHP's inability to garbage collect
1682: * objects with circular references (even in PHP 5.3). This is currently necessary
1683: * when using Propel in certain daemon or large-volumne/high-memory operations.
1684: *
1685: * @param boolean $deep Whether to also clear the references on all referrer objects.
1686: */
1687: public function clearAllReferences($deep = false)
1688: {
1689: if ($deep) {
1690: if ($this->collFeatureProds) {
1691: foreach ($this->collFeatureProds as $o) {
1692: $o->clearAllReferences($deep);
1693: }
1694: }
1695: if ($this->collFeatureAvI18ns) {
1696: foreach ($this->collFeatureAvI18ns as $o) {
1697: $o->clearAllReferences($deep);
1698: }
1699: }
1700: } // if ($deep)
1701:
1702: // i18n behavior
1703: $this->currentLocale = 'en_EN';
1704: $this->currentTranslations = null;
1705:
1706: if ($this->collFeatureProds instanceof PropelCollection) {
1707: $this->collFeatureProds->clearIterator();
1708: }
1709: $this->collFeatureProds = null;
1710: if ($this->collFeatureAvI18ns instanceof PropelCollection) {
1711: $this->collFeatureAvI18ns->clearIterator();
1712: }
1713: $this->collFeatureAvI18ns = null;
1714: $this->aFeature = null;
1715: }
1716:
1717: /**
1718: * return the string representation of this object
1719: *
1720: * @return string
1721: */
1722: public function __toString()
1723: {
1724: return (string) $this->exportTo(FeatureAvPeer::DEFAULT_STRING_FORMAT);
1725: }
1726:
1727: /**
1728: * return true is the object is in saving state
1729: *
1730: * @return boolean
1731: */
1732: public function isAlreadyInSave()
1733: {
1734: return $this->alreadyInSave;
1735: }
1736:
1737: // timestampable behavior
1738:
1739: /**
1740: * Mark the current object so that the update date doesn't get updated during next save
1741: *
1742: * @return FeatureAv The current object (for fluent API support)
1743: */
1744: public function keepUpdateDateUnchanged()
1745: {
1746: $this->modifiedColumns[] = FeatureAvPeer::UPDATED_AT;
1747:
1748: return $this;
1749: }
1750:
1751: // i18n behavior
1752:
1753: /**
1754: * Sets the locale for translations
1755: *
1756: * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
1757: *
1758: * @return FeatureAv The current object (for fluent API support)
1759: */
1760: public function setLocale($locale = 'en_EN')
1761: {
1762: $this->currentLocale = $locale;
1763:
1764: return $this;
1765: }
1766:
1767: /**
1768: * Gets the locale for translations
1769: *
1770: * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
1771: */
1772: public function getLocale()
1773: {
1774: return $this->currentLocale;
1775: }
1776:
1777: /**
1778: * Returns the current translation for a given locale
1779: *
1780: * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
1781: * @param PropelPDO $con an optional connection object
1782: *
1783: * @return FeatureAvI18n */
1784: public function getTranslation($locale = 'en_EN', PropelPDO $con = null)
1785: {
1786: if (!isset($this->currentTranslations[$locale])) {
1787: if (null !== $this->collFeatureAvI18ns) {
1788: foreach ($this->collFeatureAvI18ns as $translation) {
1789: if ($translation->getLocale() == $locale) {
1790: $this->currentTranslations[$locale] = $translation;
1791:
1792: return $translation;
1793: }
1794: }
1795: }
1796: if ($this->isNew()) {
1797: $translation = new FeatureAvI18n();
1798: $translation->setLocale($locale);
1799: } else {
1800: $translation = FeatureAvI18nQuery::create()
1801: ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
1802: ->findOneOrCreate($con);
1803: $this->currentTranslations[$locale] = $translation;
1804: }
1805: $this->addFeatureAvI18n($translation);
1806: }
1807:
1808: return $this->currentTranslations[$locale];
1809: }
1810:
1811: /**
1812: * Remove the translation for a given locale
1813: *
1814: * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
1815: * @param PropelPDO $con an optional connection object
1816: *
1817: * @return FeatureAv The current object (for fluent API support)
1818: */
1819: public function removeTranslation($locale = 'en_EN', PropelPDO $con = null)
1820: {
1821: if (!$this->isNew()) {
1822: FeatureAvI18nQuery::create()
1823: ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
1824: ->delete($con);
1825: }
1826: if (isset($this->currentTranslations[$locale])) {
1827: unset($this->currentTranslations[$locale]);
1828: }
1829: foreach ($this->collFeatureAvI18ns as $key => $translation) {
1830: if ($translation->getLocale() == $locale) {
1831: unset($this->collFeatureAvI18ns[$key]);
1832: break;
1833: }
1834: }
1835:
1836: return $this;
1837: }
1838:
1839: /**
1840: * Returns the current translation
1841: *
1842: * @param PropelPDO $con an optional connection object
1843: *
1844: * @return FeatureAvI18n */
1845: public function getCurrentTranslation(PropelPDO $con = null)
1846: {
1847: return $this->getTranslation($this->getLocale(), $con);
1848: }
1849:
1850:
1851: /**
1852: * Get the [title] column value.
1853: *
1854: * @return string
1855: */
1856: public function getTitle()
1857: {
1858: return $this->getCurrentTranslation()->getTitle();
1859: }
1860:
1861:
1862: /**
1863: * Set the value of [title] column.
1864: *
1865: * @param string $v new value
1866: * @return FeatureAvI18n The current object (for fluent API support)
1867: */
1868: public function setTitle($v)
1869: { $this->getCurrentTranslation()->setTitle($v);
1870:
1871: return $this;
1872: }
1873:
1874:
1875: /**
1876: * Get the [description] column value.
1877: *
1878: * @return string
1879: */
1880: public function getDescription()
1881: {
1882: return $this->getCurrentTranslation()->getDescription();
1883: }
1884:
1885:
1886: /**
1887: * Set the value of [description] column.
1888: *
1889: * @param string $v new value
1890: * @return FeatureAvI18n The current object (for fluent API support)
1891: */
1892: public function setDescription($v)
1893: { $this->getCurrentTranslation()->setDescription($v);
1894:
1895: return $this;
1896: }
1897:
1898:
1899: /**
1900: * Get the [chapo] column value.
1901: *
1902: * @return string
1903: */
1904: public function getChapo()
1905: {
1906: return $this->getCurrentTranslation()->getChapo();
1907: }
1908:
1909:
1910: /**
1911: * Set the value of [chapo] column.
1912: *
1913: * @param string $v new value
1914: * @return FeatureAvI18n The current object (for fluent API support)
1915: */
1916: public function setChapo($v)
1917: { $this->getCurrentTranslation()->setChapo($v);
1918:
1919: return $this;
1920: }
1921:
1922:
1923: /**
1924: * Get the [postscriptum] column value.
1925: *
1926: * @return string
1927: */
1928: public function getPostscriptum()
1929: {
1930: return $this->getCurrentTranslation()->getPostscriptum();
1931: }
1932:
1933:
1934: /**
1935: * Set the value of [postscriptum] column.
1936: *
1937: * @param string $v new value
1938: * @return FeatureAvI18n The current object (for fluent API support)
1939: */
1940: public function setPostscriptum($v)
1941: { $this->getCurrentTranslation()->setPostscriptum($v);
1942:
1943: return $this;
1944: }
1945:
1946: }
1947: