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\FeatureAvQuery;
21: use Thelia\Model\FeatureCategory;
22: use Thelia\Model\FeatureCategoryQuery;
23: use Thelia\Model\FeatureI18n;
24: use Thelia\Model\FeatureI18nQuery;
25: use Thelia\Model\FeaturePeer;
26: use Thelia\Model\FeatureProd;
27: use Thelia\Model\FeatureProdQuery;
28: use Thelia\Model\FeatureQuery;
29:
30: 31: 32: 33: 34: 35: 36:
37: abstract class BaseFeature extends BaseObject implements Persistent
38: {
39: 40: 41:
42: const PEER = 'Thelia\\Model\\FeaturePeer';
43:
44: 45: 46: 47: 48: 49:
50: protected static $peer;
51:
52: 53: 54: 55:
56: protected $startCopy = false;
57:
58: 59: 60: 61:
62: protected $id;
63:
64: 65: 66: 67: 68:
69: protected $visible;
70:
71: 72: 73: 74:
75: protected $position;
76:
77: 78: 79: 80:
81: protected $created_at;
82:
83: 84: 85: 86:
87: protected $updated_at;
88:
89: 90: 91:
92: protected $collFeatureAvs;
93: protected $collFeatureAvsPartial;
94:
95: 96: 97:
98: protected $collFeatureProds;
99: protected $collFeatureProdsPartial;
100:
101: 102: 103:
104: protected $collFeatureCategorys;
105: protected $collFeatureCategorysPartial;
106:
107: 108: 109:
110: protected $collFeatureI18ns;
111: protected $collFeatureI18nsPartial;
112:
113: 114: 115: 116: 117:
118: protected $alreadyInSave = false;
119:
120: 121: 122: 123: 124:
125: protected $alreadyInValidation = false;
126:
127: 128: 129: 130:
131: protected $alreadyInClearAllReferencesDeep = false;
132:
133:
134:
135: 136: 137: 138:
139: protected $currentLocale = 'en_US';
140:
141: 142: 143: 144:
145: protected $currentTranslations;
146:
147: 148: 149: 150:
151: protected $featureAvsScheduledForDeletion = null;
152:
153: 154: 155: 156:
157: protected $featureProdsScheduledForDeletion = null;
158:
159: 160: 161: 162:
163: protected $featureCategorysScheduledForDeletion = null;
164:
165: 166: 167: 168:
169: protected $featureI18nsScheduledForDeletion = null;
170:
171: 172: 173: 174: 175: 176:
177: public function applyDefaultValues()
178: {
179: $this->visible = 0;
180: }
181:
182: 183: 184: 185:
186: public function __construct()
187: {
188: parent::__construct();
189: $this->applyDefaultValues();
190: }
191:
192: 193: 194: 195: 196:
197: public function getId()
198: {
199: return $this->id;
200: }
201:
202: 203: 204: 205: 206:
207: public function getVisible()
208: {
209: return $this->visible;
210: }
211:
212: 213: 214: 215: 216:
217: public function getPosition()
218: {
219: return $this->position;
220: }
221:
222: 223: 224: 225: 226: 227: 228: 229: 230:
231: public function getCreatedAt($format = 'Y-m-d H:i:s')
232: {
233: if ($this->created_at === null) {
234: return null;
235: }
236:
237: if ($this->created_at === '0000-00-00 00:00:00') {
238:
239:
240: return null;
241: }
242:
243: try {
244: $dt = new DateTime($this->created_at);
245: } catch (Exception $x) {
246: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
247: }
248:
249: if ($format === null) {
250:
251: return $dt;
252: }
253:
254: if (strpos($format, '%') !== false) {
255: return strftime($format, $dt->format('U'));
256: }
257:
258: return $dt->format($format);
259:
260: }
261:
262: 263: 264: 265: 266: 267: 268: 269: 270:
271: public function getUpdatedAt($format = 'Y-m-d H:i:s')
272: {
273: if ($this->updated_at === null) {
274: return null;
275: }
276:
277: if ($this->updated_at === '0000-00-00 00:00:00') {
278:
279:
280: return null;
281: }
282:
283: try {
284: $dt = new DateTime($this->updated_at);
285: } catch (Exception $x) {
286: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
287: }
288:
289: if ($format === null) {
290:
291: return $dt;
292: }
293:
294: if (strpos($format, '%') !== false) {
295: return strftime($format, $dt->format('U'));
296: }
297:
298: return $dt->format($format);
299:
300: }
301:
302: 303: 304: 305: 306: 307:
308: public function setId($v)
309: {
310: if ($v !== null && is_numeric($v)) {
311: $v = (int) $v;
312: }
313:
314: if ($this->id !== $v) {
315: $this->id = $v;
316: $this->modifiedColumns[] = FeaturePeer::ID;
317: }
318:
319:
320: return $this;
321: }
322:
323: 324: 325: 326: 327: 328:
329: public function setVisible($v)
330: {
331: if ($v !== null && is_numeric($v)) {
332: $v = (int) $v;
333: }
334:
335: if ($this->visible !== $v) {
336: $this->visible = $v;
337: $this->modifiedColumns[] = FeaturePeer::VISIBLE;
338: }
339:
340:
341: return $this;
342: }
343:
344: 345: 346: 347: 348: 349:
350: public function setPosition($v)
351: {
352: if ($v !== null && is_numeric($v)) {
353: $v = (int) $v;
354: }
355:
356: if ($this->position !== $v) {
357: $this->position = $v;
358: $this->modifiedColumns[] = FeaturePeer::POSITION;
359: }
360:
361:
362: return $this;
363: }
364:
365: 366: 367: 368: 369: 370: 371:
372: public function setCreatedAt($v)
373: {
374: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
375: if ($this->created_at !== null || $dt !== null) {
376: $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
377: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
378: if ($currentDateAsString !== $newDateAsString) {
379: $this->created_at = $newDateAsString;
380: $this->modifiedColumns[] = FeaturePeer::CREATED_AT;
381: }
382: }
383:
384:
385: return $this;
386: }
387:
388: 389: 390: 391: 392: 393: 394:
395: public function setUpdatedAt($v)
396: {
397: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
398: if ($this->updated_at !== null || $dt !== null) {
399: $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
400: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
401: if ($currentDateAsString !== $newDateAsString) {
402: $this->updated_at = $newDateAsString;
403: $this->modifiedColumns[] = FeaturePeer::UPDATED_AT;
404: }
405: }
406:
407:
408: return $this;
409: }
410:
411: 412: 413: 414: 415: 416: 417: 418:
419: public function hasOnlyDefaultValues()
420: {
421: if ($this->visible !== 0) {
422: return false;
423: }
424:
425:
426: return true;
427: }
428:
429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442:
443: public function hydrate($row, $startcol = 0, $rehydrate = false)
444: {
445: try {
446:
447: $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
448: $this->visible = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
449: $this->position = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
450: $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
451: $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
452: $this->resetModified();
453:
454: $this->setNew(false);
455:
456: if ($rehydrate) {
457: $this->ensureConsistency();
458: }
459: $this->postHydrate($row, $startcol, $rehydrate);
460: return $startcol + 5;
461:
462: } catch (Exception $e) {
463: throw new PropelException("Error populating Feature object", $e);
464: }
465: }
466:
467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479:
480: public function ensureConsistency()
481: {
482:
483: }
484:
485: 486: 487: 488: 489: 490: 491: 492: 493: 494:
495: public function reload($deep = false, PropelPDO $con = null)
496: {
497: if ($this->isDeleted()) {
498: throw new PropelException("Cannot reload a deleted object.");
499: }
500:
501: if ($this->isNew()) {
502: throw new PropelException("Cannot reload an unsaved object.");
503: }
504:
505: if ($con === null) {
506: $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
507: }
508:
509:
510:
511:
512: $stmt = FeaturePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
513: $row = $stmt->fetch(PDO::FETCH_NUM);
514: $stmt->closeCursor();
515: if (!$row) {
516: throw new PropelException('Cannot find matching row in the database to reload object values.');
517: }
518: $this->hydrate($row, 0, true);
519:
520: if ($deep) {
521:
522: $this->collFeatureAvs = null;
523:
524: $this->collFeatureProds = null;
525:
526: $this->collFeatureCategorys = null;
527:
528: $this->collFeatureI18ns = null;
529:
530: }
531: }
532:
533: 534: 535: 536: 537: 538: 539: 540: 541: 542:
543: public function delete(PropelPDO $con = null)
544: {
545: if ($this->isDeleted()) {
546: throw new PropelException("This object has already been deleted.");
547: }
548:
549: if ($con === null) {
550: $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
551: }
552:
553: $con->beginTransaction();
554: try {
555: $deleteQuery = FeatureQuery::create()
556: ->filterByPrimaryKey($this->getPrimaryKey());
557: $ret = $this->preDelete($con);
558: if ($ret) {
559: $deleteQuery->delete($con);
560: $this->postDelete($con);
561: $con->commit();
562: $this->setDeleted(true);
563: } else {
564: $con->commit();
565: }
566: } catch (Exception $e) {
567: $con->rollBack();
568: throw $e;
569: }
570: }
571:
572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585:
586: public function save(PropelPDO $con = null)
587: {
588: if ($this->isDeleted()) {
589: throw new PropelException("You cannot save an object that has been deleted.");
590: }
591:
592: if ($con === null) {
593: $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
594: }
595:
596: $con->beginTransaction();
597: $isInsert = $this->isNew();
598: try {
599: $ret = $this->preSave($con);
600: if ($isInsert) {
601: $ret = $ret && $this->preInsert($con);
602:
603: if (!$this->isColumnModified(FeaturePeer::CREATED_AT)) {
604: $this->setCreatedAt(time());
605: }
606: if (!$this->isColumnModified(FeaturePeer::UPDATED_AT)) {
607: $this->setUpdatedAt(time());
608: }
609: } else {
610: $ret = $ret && $this->preUpdate($con);
611:
612: if ($this->isModified() && !$this->isColumnModified(FeaturePeer::UPDATED_AT)) {
613: $this->setUpdatedAt(time());
614: }
615: }
616: if ($ret) {
617: $affectedRows = $this->doSave($con);
618: if ($isInsert) {
619: $this->postInsert($con);
620: } else {
621: $this->postUpdate($con);
622: }
623: $this->postSave($con);
624: FeaturePeer::addInstanceToPool($this);
625: } else {
626: $affectedRows = 0;
627: }
628: $con->commit();
629:
630: return $affectedRows;
631: } catch (Exception $e) {
632: $con->rollBack();
633: throw $e;
634: }
635: }
636:
637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647:
648: protected function doSave(PropelPDO $con)
649: {
650: $affectedRows = 0;
651: if (!$this->alreadyInSave) {
652: $this->alreadyInSave = true;
653:
654: if ($this->isNew() || $this->isModified()) {
655:
656: if ($this->isNew()) {
657: $this->doInsert($con);
658: } else {
659: $this->doUpdate($con);
660: }
661: $affectedRows += 1;
662: $this->resetModified();
663: }
664:
665: if ($this->featureAvsScheduledForDeletion !== null) {
666: if (!$this->featureAvsScheduledForDeletion->isEmpty()) {
667: FeatureAvQuery::create()
668: ->filterByPrimaryKeys($this->featureAvsScheduledForDeletion->getPrimaryKeys(false))
669: ->delete($con);
670: $this->featureAvsScheduledForDeletion = null;
671: }
672: }
673:
674: if ($this->collFeatureAvs !== null) {
675: foreach ($this->collFeatureAvs as $referrerFK) {
676: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
677: $affectedRows += $referrerFK->save($con);
678: }
679: }
680: }
681:
682: if ($this->featureProdsScheduledForDeletion !== null) {
683: if (!$this->featureProdsScheduledForDeletion->isEmpty()) {
684: FeatureProdQuery::create()
685: ->filterByPrimaryKeys($this->featureProdsScheduledForDeletion->getPrimaryKeys(false))
686: ->delete($con);
687: $this->featureProdsScheduledForDeletion = null;
688: }
689: }
690:
691: if ($this->collFeatureProds !== null) {
692: foreach ($this->collFeatureProds as $referrerFK) {
693: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
694: $affectedRows += $referrerFK->save($con);
695: }
696: }
697: }
698:
699: if ($this->featureCategorysScheduledForDeletion !== null) {
700: if (!$this->featureCategorysScheduledForDeletion->isEmpty()) {
701: FeatureCategoryQuery::create()
702: ->filterByPrimaryKeys($this->featureCategorysScheduledForDeletion->getPrimaryKeys(false))
703: ->delete($con);
704: $this->featureCategorysScheduledForDeletion = null;
705: }
706: }
707:
708: if ($this->collFeatureCategorys !== null) {
709: foreach ($this->collFeatureCategorys as $referrerFK) {
710: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
711: $affectedRows += $referrerFK->save($con);
712: }
713: }
714: }
715:
716: if ($this->featureI18nsScheduledForDeletion !== null) {
717: if (!$this->featureI18nsScheduledForDeletion->isEmpty()) {
718: FeatureI18nQuery::create()
719: ->filterByPrimaryKeys($this->featureI18nsScheduledForDeletion->getPrimaryKeys(false))
720: ->delete($con);
721: $this->featureI18nsScheduledForDeletion = null;
722: }
723: }
724:
725: if ($this->collFeatureI18ns !== null) {
726: foreach ($this->collFeatureI18ns as $referrerFK) {
727: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
728: $affectedRows += $referrerFK->save($con);
729: }
730: }
731: }
732:
733: $this->alreadyInSave = false;
734:
735: }
736:
737: return $affectedRows;
738: }
739:
740: 741: 742: 743: 744: 745: 746: 747:
748: protected function doInsert(PropelPDO $con)
749: {
750: $modifiedColumns = array();
751: $index = 0;
752:
753: $this->modifiedColumns[] = FeaturePeer::ID;
754: if (null !== $this->id) {
755: throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeaturePeer::ID . ')');
756: }
757:
758:
759: if ($this->isColumnModified(FeaturePeer::ID)) {
760: $modifiedColumns[':p' . $index++] = '`id`';
761: }
762: if ($this->isColumnModified(FeaturePeer::VISIBLE)) {
763: $modifiedColumns[':p' . $index++] = '`visible`';
764: }
765: if ($this->isColumnModified(FeaturePeer::POSITION)) {
766: $modifiedColumns[':p' . $index++] = '`position`';
767: }
768: if ($this->isColumnModified(FeaturePeer::CREATED_AT)) {
769: $modifiedColumns[':p' . $index++] = '`created_at`';
770: }
771: if ($this->isColumnModified(FeaturePeer::UPDATED_AT)) {
772: $modifiedColumns[':p' . $index++] = '`updated_at`';
773: }
774:
775: $sql = sprintf(
776: 'INSERT INTO `feature` (%s) VALUES (%s)',
777: implode(', ', $modifiedColumns),
778: implode(', ', array_keys($modifiedColumns))
779: );
780:
781: try {
782: $stmt = $con->prepare($sql);
783: foreach ($modifiedColumns as $identifier => $columnName) {
784: switch ($columnName) {
785: case '`id`':
786: $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
787: break;
788: case '`visible`':
789: $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
790: break;
791: case '`position`':
792: $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
793: break;
794: case '`created_at`':
795: $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
796: break;
797: case '`updated_at`':
798: $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
799: break;
800: }
801: }
802: $stmt->execute();
803: } catch (Exception $e) {
804: Propel::log($e->getMessage(), Propel::LOG_ERR);
805: throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
806: }
807:
808: try {
809: $pk = $con->lastInsertId();
810: } catch (Exception $e) {
811: throw new PropelException('Unable to get autoincrement id.', $e);
812: }
813: $this->setId($pk);
814:
815: $this->setNew(false);
816: }
817:
818: 819: 820: 821: 822: 823: 824:
825: protected function doUpdate(PropelPDO $con)
826: {
827: $selectCriteria = $this->buildPkeyCriteria();
828: $valuesCriteria = $this->buildCriteria();
829: BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
830: }
831:
832: 833: 834: 835:
836: protected $validationFailures = array();
837:
838: 839: 840: 841: 842: 843: 844:
845: public function getValidationFailures()
846: {
847: return $this->validationFailures;
848: }
849:
850: 851: 852: 853: 854: 855: 856: 857: 858: 859: 860:
861: public function validate($columns = null)
862: {
863: $res = $this->doValidate($columns);
864: if ($res === true) {
865: $this->validationFailures = array();
866:
867: return true;
868: }
869:
870: $this->validationFailures = $res;
871:
872: return false;
873: }
874:
875: 876: 877: 878: 879: 880: 881: 882: 883: 884:
885: protected function doValidate($columns = null)
886: {
887: if (!$this->alreadyInValidation) {
888: $this->alreadyInValidation = true;
889: $retval = null;
890:
891: $failureMap = array();
892:
893:
894: if (($retval = FeaturePeer::doValidate($this, $columns)) !== true) {
895: $failureMap = array_merge($failureMap, $retval);
896: }
897:
898:
899: if ($this->collFeatureAvs !== null) {
900: foreach ($this->collFeatureAvs as $referrerFK) {
901: if (!$referrerFK->validate($columns)) {
902: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
903: }
904: }
905: }
906:
907: if ($this->collFeatureProds !== null) {
908: foreach ($this->collFeatureProds as $referrerFK) {
909: if (!$referrerFK->validate($columns)) {
910: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
911: }
912: }
913: }
914:
915: if ($this->collFeatureCategorys !== null) {
916: foreach ($this->collFeatureCategorys as $referrerFK) {
917: if (!$referrerFK->validate($columns)) {
918: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
919: }
920: }
921: }
922:
923: if ($this->collFeatureI18ns !== null) {
924: foreach ($this->collFeatureI18ns as $referrerFK) {
925: if (!$referrerFK->validate($columns)) {
926: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
927: }
928: }
929: }
930:
931:
932: $this->alreadyInValidation = false;
933: }
934:
935: return (!empty($failureMap) ? $failureMap : true);
936: }
937:
938: 939: 940: 941: 942: 943: 944: 945: 946: 947:
948: public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
949: {
950: $pos = FeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
951: $field = $this->getByPosition($pos);
952:
953: return $field;
954: }
955:
956: 957: 958: 959: 960: 961: 962:
963: public function getByPosition($pos)
964: {
965: switch ($pos) {
966: case 0:
967: return $this->getId();
968: break;
969: case 1:
970: return $this->getVisible();
971: break;
972: case 2:
973: return $this->getPosition();
974: break;
975: case 3:
976: return $this->getCreatedAt();
977: break;
978: case 4:
979: return $this->getUpdatedAt();
980: break;
981: default:
982: return null;
983: break;
984: }
985: }
986:
987: 988: 989: 990: 991: 992: 993: 994: 995: 996: 997: 998: 999: 1000: 1001:
1002: public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
1003: {
1004: if (isset($alreadyDumpedObjects['Feature'][$this->getPrimaryKey()])) {
1005: return '*RECURSION*';
1006: }
1007: $alreadyDumpedObjects['Feature'][$this->getPrimaryKey()] = true;
1008: $keys = FeaturePeer::getFieldNames($keyType);
1009: $result = array(
1010: $keys[0] => $this->getId(),
1011: $keys[1] => $this->getVisible(),
1012: $keys[2] => $this->getPosition(),
1013: $keys[3] => $this->getCreatedAt(),
1014: $keys[4] => $this->getUpdatedAt(),
1015: );
1016: if ($includeForeignObjects) {
1017: if (null !== $this->collFeatureAvs) {
1018: $result['FeatureAvs'] = $this->collFeatureAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1019: }
1020: if (null !== $this->collFeatureProds) {
1021: $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1022: }
1023: if (null !== $this->collFeatureCategorys) {
1024: $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1025: }
1026: if (null !== $this->collFeatureI18ns) {
1027: $result['FeatureI18ns'] = $this->collFeatureI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1028: }
1029: }
1030:
1031: return $result;
1032: }
1033:
1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044:
1045: public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
1046: {
1047: $pos = FeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1048:
1049: $this->setByPosition($pos, $value);
1050: }
1051:
1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059:
1060: public function setByPosition($pos, $value)
1061: {
1062: switch ($pos) {
1063: case 0:
1064: $this->setId($value);
1065: break;
1066: case 1:
1067: $this->setVisible($value);
1068: break;
1069: case 2:
1070: $this->setPosition($value);
1071: break;
1072: case 3:
1073: $this->setCreatedAt($value);
1074: break;
1075: case 4:
1076: $this->setUpdatedAt($value);
1077: break;
1078: }
1079: }
1080:
1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097:
1098: public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
1099: {
1100: $keys = FeaturePeer::getFieldNames($keyType);
1101:
1102: if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
1103: if (array_key_exists($keys[1], $arr)) $this->setVisible($arr[$keys[1]]);
1104: if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]);
1105: if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
1106: if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
1107: }
1108:
1109: 1110: 1111: 1112: 1113:
1114: public function buildCriteria()
1115: {
1116: $criteria = new Criteria(FeaturePeer::DATABASE_NAME);
1117:
1118: if ($this->isColumnModified(FeaturePeer::ID)) $criteria->add(FeaturePeer::ID, $this->id);
1119: if ($this->isColumnModified(FeaturePeer::VISIBLE)) $criteria->add(FeaturePeer::VISIBLE, $this->visible);
1120: if ($this->isColumnModified(FeaturePeer::POSITION)) $criteria->add(FeaturePeer::POSITION, $this->position);
1121: if ($this->isColumnModified(FeaturePeer::CREATED_AT)) $criteria->add(FeaturePeer::CREATED_AT, $this->created_at);
1122: if ($this->isColumnModified(FeaturePeer::UPDATED_AT)) $criteria->add(FeaturePeer::UPDATED_AT, $this->updated_at);
1123:
1124: return $criteria;
1125: }
1126:
1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134:
1135: public function buildPkeyCriteria()
1136: {
1137: $criteria = new Criteria(FeaturePeer::DATABASE_NAME);
1138: $criteria->add(FeaturePeer::ID, $this->id);
1139:
1140: return $criteria;
1141: }
1142:
1143: 1144: 1145: 1146:
1147: public function getPrimaryKey()
1148: {
1149: return $this->getId();
1150: }
1151:
1152: 1153: 1154: 1155: 1156: 1157:
1158: public function setPrimaryKey($key)
1159: {
1160: $this->setId($key);
1161: }
1162:
1163: 1164: 1165: 1166:
1167: public function isPrimaryKeyNull()
1168: {
1169:
1170: return null === $this->getId();
1171: }
1172:
1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183:
1184: public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1185: {
1186: $copyObj->setVisible($this->getVisible());
1187: $copyObj->setPosition($this->getPosition());
1188: $copyObj->setCreatedAt($this->getCreatedAt());
1189: $copyObj->setUpdatedAt($this->getUpdatedAt());
1190:
1191: if ($deepCopy && !$this->startCopy) {
1192:
1193:
1194: $copyObj->setNew(false);
1195:
1196: $this->startCopy = true;
1197:
1198: foreach ($this->getFeatureAvs() as $relObj) {
1199: if ($relObj !== $this) {
1200: $copyObj->addFeatureAv($relObj->copy($deepCopy));
1201: }
1202: }
1203:
1204: foreach ($this->getFeatureProds() as $relObj) {
1205: if ($relObj !== $this) {
1206: $copyObj->addFeatureProd($relObj->copy($deepCopy));
1207: }
1208: }
1209:
1210: foreach ($this->getFeatureCategorys() as $relObj) {
1211: if ($relObj !== $this) {
1212: $copyObj->addFeatureCategory($relObj->copy($deepCopy));
1213: }
1214: }
1215:
1216: foreach ($this->getFeatureI18ns() as $relObj) {
1217: if ($relObj !== $this) {
1218: $copyObj->addFeatureI18n($relObj->copy($deepCopy));
1219: }
1220: }
1221:
1222:
1223: $this->startCopy = false;
1224: }
1225:
1226: if ($makeNew) {
1227: $copyObj->setNew(true);
1228: $copyObj->setId(NULL);
1229: }
1230: }
1231:
1232: 1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243:
1244: public function copy($deepCopy = false)
1245: {
1246:
1247: $clazz = get_class($this);
1248: $copyObj = new $clazz();
1249: $this->copyInto($copyObj, $deepCopy);
1250:
1251: return $copyObj;
1252: }
1253:
1254: 1255: 1256: 1257: 1258: 1259: 1260: 1261: 1262:
1263: public function getPeer()
1264: {
1265: if (self::$peer === null) {
1266: self::$peer = new FeaturePeer();
1267: }
1268:
1269: return self::$peer;
1270: }
1271:
1272:
1273: 1274: 1275: 1276: 1277: 1278: 1279: 1280:
1281: public function initRelation($relationName)
1282: {
1283: if ('FeatureAv' == $relationName) {
1284: $this->initFeatureAvs();
1285: }
1286: if ('FeatureProd' == $relationName) {
1287: $this->initFeatureProds();
1288: }
1289: if ('FeatureCategory' == $relationName) {
1290: $this->initFeatureCategorys();
1291: }
1292: if ('FeatureI18n' == $relationName) {
1293: $this->initFeatureI18ns();
1294: }
1295: }
1296:
1297: 1298: 1299: 1300: 1301: 1302: 1303: 1304: 1305:
1306: public function clearFeatureAvs()
1307: {
1308: $this->collFeatureAvs = null;
1309: $this->collFeatureAvsPartial = null;
1310:
1311: return $this;
1312: }
1313:
1314: 1315: 1316: 1317: 1318:
1319: public function resetPartialFeatureAvs($v = true)
1320: {
1321: $this->collFeatureAvsPartial = $v;
1322: }
1323:
1324: 1325: 1326: 1327: 1328: 1329: 1330: 1331: 1332: 1333: 1334: 1335:
1336: public function initFeatureAvs($overrideExisting = true)
1337: {
1338: if (null !== $this->collFeatureAvs && !$overrideExisting) {
1339: return;
1340: }
1341: $this->collFeatureAvs = new PropelObjectCollection();
1342: $this->collFeatureAvs->setModel('FeatureAv');
1343: }
1344:
1345: 1346: 1347: 1348: 1349: 1350: 1351: 1352: 1353: 1354: 1355: 1356: 1357: 1358:
1359: public function getFeatureAvs($criteria = null, PropelPDO $con = null)
1360: {
1361: $partial = $this->collFeatureAvsPartial && !$this->isNew();
1362: if (null === $this->collFeatureAvs || null !== $criteria || $partial) {
1363: if ($this->isNew() && null === $this->collFeatureAvs) {
1364:
1365: $this->initFeatureAvs();
1366: } else {
1367: $collFeatureAvs = FeatureAvQuery::create(null, $criteria)
1368: ->filterByFeature($this)
1369: ->find($con);
1370: if (null !== $criteria) {
1371: if (false !== $this->collFeatureAvsPartial && count($collFeatureAvs)) {
1372: $this->initFeatureAvs(false);
1373:
1374: foreach($collFeatureAvs as $obj) {
1375: if (false == $this->collFeatureAvs->contains($obj)) {
1376: $this->collFeatureAvs->append($obj);
1377: }
1378: }
1379:
1380: $this->collFeatureAvsPartial = true;
1381: }
1382:
1383: $collFeatureAvs->getInternalIterator()->rewind();
1384: return $collFeatureAvs;
1385: }
1386:
1387: if($partial && $this->collFeatureAvs) {
1388: foreach($this->collFeatureAvs as $obj) {
1389: if($obj->isNew()) {
1390: $collFeatureAvs[] = $obj;
1391: }
1392: }
1393: }
1394:
1395: $this->collFeatureAvs = $collFeatureAvs;
1396: $this->collFeatureAvsPartial = false;
1397: }
1398: }
1399:
1400: return $this->collFeatureAvs;
1401: }
1402:
1403: 1404: 1405: 1406: 1407: 1408: 1409: 1410: 1411: 1412:
1413: public function setFeatureAvs(PropelCollection $featureAvs, PropelPDO $con = null)
1414: {
1415: $featureAvsToDelete = $this->getFeatureAvs(new Criteria(), $con)->diff($featureAvs);
1416:
1417: $this->featureAvsScheduledForDeletion = unserialize(serialize($featureAvsToDelete));
1418:
1419: foreach ($featureAvsToDelete as $featureAvRemoved) {
1420: $featureAvRemoved->setFeature(null);
1421: }
1422:
1423: $this->collFeatureAvs = null;
1424: foreach ($featureAvs as $featureAv) {
1425: $this->addFeatureAv($featureAv);
1426: }
1427:
1428: $this->collFeatureAvs = $featureAvs;
1429: $this->collFeatureAvsPartial = false;
1430:
1431: return $this;
1432: }
1433:
1434: 1435: 1436: 1437: 1438: 1439: 1440: 1441: 1442:
1443: public function countFeatureAvs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1444: {
1445: $partial = $this->collFeatureAvsPartial && !$this->isNew();
1446: if (null === $this->collFeatureAvs || null !== $criteria || $partial) {
1447: if ($this->isNew() && null === $this->collFeatureAvs) {
1448: return 0;
1449: }
1450:
1451: if($partial && !$criteria) {
1452: return count($this->getFeatureAvs());
1453: }
1454: $query = FeatureAvQuery::create(null, $criteria);
1455: if ($distinct) {
1456: $query->distinct();
1457: }
1458:
1459: return $query
1460: ->filterByFeature($this)
1461: ->count($con);
1462: }
1463:
1464: return count($this->collFeatureAvs);
1465: }
1466:
1467: 1468: 1469: 1470: 1471: 1472: 1473:
1474: public function addFeatureAv(FeatureAv $l)
1475: {
1476: if ($this->collFeatureAvs === null) {
1477: $this->initFeatureAvs();
1478: $this->collFeatureAvsPartial = true;
1479: }
1480: if (!in_array($l, $this->collFeatureAvs->getArrayCopy(), true)) {
1481: $this->doAddFeatureAv($l);
1482: }
1483:
1484: return $this;
1485: }
1486:
1487: 1488: 1489:
1490: protected function doAddFeatureAv($featureAv)
1491: {
1492: $this->collFeatureAvs[]= $featureAv;
1493: $featureAv->setFeature($this);
1494: }
1495:
1496: 1497: 1498: 1499:
1500: public function removeFeatureAv($featureAv)
1501: {
1502: if ($this->getFeatureAvs()->contains($featureAv)) {
1503: $this->collFeatureAvs->remove($this->collFeatureAvs->search($featureAv));
1504: if (null === $this->featureAvsScheduledForDeletion) {
1505: $this->featureAvsScheduledForDeletion = clone $this->collFeatureAvs;
1506: $this->featureAvsScheduledForDeletion->clear();
1507: }
1508: $this->featureAvsScheduledForDeletion[]= clone $featureAv;
1509: $featureAv->setFeature(null);
1510: }
1511:
1512: return $this;
1513: }
1514:
1515: 1516: 1517: 1518: 1519: 1520: 1521: 1522: 1523:
1524: public function clearFeatureProds()
1525: {
1526: $this->collFeatureProds = null;
1527: $this->collFeatureProdsPartial = null;
1528:
1529: return $this;
1530: }
1531:
1532: 1533: 1534: 1535: 1536:
1537: public function resetPartialFeatureProds($v = true)
1538: {
1539: $this->collFeatureProdsPartial = $v;
1540: }
1541:
1542: 1543: 1544: 1545: 1546: 1547: 1548: 1549: 1550: 1551: 1552: 1553:
1554: public function initFeatureProds($overrideExisting = true)
1555: {
1556: if (null !== $this->collFeatureProds && !$overrideExisting) {
1557: return;
1558: }
1559: $this->collFeatureProds = new PropelObjectCollection();
1560: $this->collFeatureProds->setModel('FeatureProd');
1561: }
1562:
1563: 1564: 1565: 1566: 1567: 1568: 1569: 1570: 1571: 1572: 1573: 1574: 1575: 1576:
1577: public function getFeatureProds($criteria = null, PropelPDO $con = null)
1578: {
1579: $partial = $this->collFeatureProdsPartial && !$this->isNew();
1580: if (null === $this->collFeatureProds || null !== $criteria || $partial) {
1581: if ($this->isNew() && null === $this->collFeatureProds) {
1582:
1583: $this->initFeatureProds();
1584: } else {
1585: $collFeatureProds = FeatureProdQuery::create(null, $criteria)
1586: ->filterByFeature($this)
1587: ->find($con);
1588: if (null !== $criteria) {
1589: if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) {
1590: $this->initFeatureProds(false);
1591:
1592: foreach($collFeatureProds as $obj) {
1593: if (false == $this->collFeatureProds->contains($obj)) {
1594: $this->collFeatureProds->append($obj);
1595: }
1596: }
1597:
1598: $this->collFeatureProdsPartial = true;
1599: }
1600:
1601: $collFeatureProds->getInternalIterator()->rewind();
1602: return $collFeatureProds;
1603: }
1604:
1605: if($partial && $this->collFeatureProds) {
1606: foreach($this->collFeatureProds as $obj) {
1607: if($obj->isNew()) {
1608: $collFeatureProds[] = $obj;
1609: }
1610: }
1611: }
1612:
1613: $this->collFeatureProds = $collFeatureProds;
1614: $this->collFeatureProdsPartial = false;
1615: }
1616: }
1617:
1618: return $this->collFeatureProds;
1619: }
1620:
1621: 1622: 1623: 1624: 1625: 1626: 1627: 1628: 1629: 1630:
1631: public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null)
1632: {
1633: $featureProdsToDelete = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds);
1634:
1635: $this->featureProdsScheduledForDeletion = unserialize(serialize($featureProdsToDelete));
1636:
1637: foreach ($featureProdsToDelete as $featureProdRemoved) {
1638: $featureProdRemoved->setFeature(null);
1639: }
1640:
1641: $this->collFeatureProds = null;
1642: foreach ($featureProds as $featureProd) {
1643: $this->addFeatureProd($featureProd);
1644: }
1645:
1646: $this->collFeatureProds = $featureProds;
1647: $this->collFeatureProdsPartial = false;
1648:
1649: return $this;
1650: }
1651:
1652: 1653: 1654: 1655: 1656: 1657: 1658: 1659: 1660:
1661: public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1662: {
1663: $partial = $this->collFeatureProdsPartial && !$this->isNew();
1664: if (null === $this->collFeatureProds || null !== $criteria || $partial) {
1665: if ($this->isNew() && null === $this->collFeatureProds) {
1666: return 0;
1667: }
1668:
1669: if($partial && !$criteria) {
1670: return count($this->getFeatureProds());
1671: }
1672: $query = FeatureProdQuery::create(null, $criteria);
1673: if ($distinct) {
1674: $query->distinct();
1675: }
1676:
1677: return $query
1678: ->filterByFeature($this)
1679: ->count($con);
1680: }
1681:
1682: return count($this->collFeatureProds);
1683: }
1684:
1685: 1686: 1687: 1688: 1689: 1690: 1691:
1692: public function addFeatureProd(FeatureProd $l)
1693: {
1694: if ($this->collFeatureProds === null) {
1695: $this->initFeatureProds();
1696: $this->collFeatureProdsPartial = true;
1697: }
1698: if (!in_array($l, $this->collFeatureProds->getArrayCopy(), true)) {
1699: $this->doAddFeatureProd($l);
1700: }
1701:
1702: return $this;
1703: }
1704:
1705: 1706: 1707:
1708: protected function doAddFeatureProd($featureProd)
1709: {
1710: $this->collFeatureProds[]= $featureProd;
1711: $featureProd->setFeature($this);
1712: }
1713:
1714: 1715: 1716: 1717:
1718: public function removeFeatureProd($featureProd)
1719: {
1720: if ($this->getFeatureProds()->contains($featureProd)) {
1721: $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd));
1722: if (null === $this->featureProdsScheduledForDeletion) {
1723: $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds;
1724: $this->featureProdsScheduledForDeletion->clear();
1725: }
1726: $this->featureProdsScheduledForDeletion[]= clone $featureProd;
1727: $featureProd->setFeature(null);
1728: }
1729:
1730: return $this;
1731: }
1732:
1733:
1734: 1735: 1736: 1737: 1738: 1739: 1740: 1741: 1742: 1743: 1744: 1745: 1746: 1747: 1748: 1749:
1750: public function getFeatureProdsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1751: {
1752: $query = FeatureProdQuery::create(null, $criteria);
1753: $query->joinWith('Product', $join_behavior);
1754:
1755: return $this->getFeatureProds($query, $con);
1756: }
1757:
1758:
1759: 1760: 1761: 1762: 1763: 1764: 1765: 1766: 1767: 1768: 1769: 1770: 1771: 1772: 1773: 1774:
1775: public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1776: {
1777: $query = FeatureProdQuery::create(null, $criteria);
1778: $query->joinWith('FeatureAv', $join_behavior);
1779:
1780: return $this->getFeatureProds($query, $con);
1781: }
1782:
1783: 1784: 1785: 1786: 1787: 1788: 1789: 1790: 1791:
1792: public function clearFeatureCategorys()
1793: {
1794: $this->collFeatureCategorys = null;
1795: $this->collFeatureCategorysPartial = null;
1796:
1797: return $this;
1798: }
1799:
1800: 1801: 1802: 1803: 1804:
1805: public function resetPartialFeatureCategorys($v = true)
1806: {
1807: $this->collFeatureCategorysPartial = $v;
1808: }
1809:
1810: 1811: 1812: 1813: 1814: 1815: 1816: 1817: 1818: 1819: 1820: 1821:
1822: public function initFeatureCategorys($overrideExisting = true)
1823: {
1824: if (null !== $this->collFeatureCategorys && !$overrideExisting) {
1825: return;
1826: }
1827: $this->collFeatureCategorys = new PropelObjectCollection();
1828: $this->collFeatureCategorys->setModel('FeatureCategory');
1829: }
1830:
1831: 1832: 1833: 1834: 1835: 1836: 1837: 1838: 1839: 1840: 1841: 1842: 1843: 1844:
1845: public function getFeatureCategorys($criteria = null, PropelPDO $con = null)
1846: {
1847: $partial = $this->collFeatureCategorysPartial && !$this->isNew();
1848: if (null === $this->collFeatureCategorys || null !== $criteria || $partial) {
1849: if ($this->isNew() && null === $this->collFeatureCategorys) {
1850:
1851: $this->initFeatureCategorys();
1852: } else {
1853: $collFeatureCategorys = FeatureCategoryQuery::create(null, $criteria)
1854: ->filterByFeature($this)
1855: ->find($con);
1856: if (null !== $criteria) {
1857: if (false !== $this->collFeatureCategorysPartial && count($collFeatureCategorys)) {
1858: $this->initFeatureCategorys(false);
1859:
1860: foreach($collFeatureCategorys as $obj) {
1861: if (false == $this->collFeatureCategorys->contains($obj)) {
1862: $this->collFeatureCategorys->append($obj);
1863: }
1864: }
1865:
1866: $this->collFeatureCategorysPartial = true;
1867: }
1868:
1869: $collFeatureCategorys->getInternalIterator()->rewind();
1870: return $collFeatureCategorys;
1871: }
1872:
1873: if($partial && $this->collFeatureCategorys) {
1874: foreach($this->collFeatureCategorys as $obj) {
1875: if($obj->isNew()) {
1876: $collFeatureCategorys[] = $obj;
1877: }
1878: }
1879: }
1880:
1881: $this->collFeatureCategorys = $collFeatureCategorys;
1882: $this->collFeatureCategorysPartial = false;
1883: }
1884: }
1885:
1886: return $this->collFeatureCategorys;
1887: }
1888:
1889: 1890: 1891: 1892: 1893: 1894: 1895: 1896: 1897: 1898:
1899: public function setFeatureCategorys(PropelCollection $featureCategorys, PropelPDO $con = null)
1900: {
1901: $featureCategorysToDelete = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys);
1902:
1903: $this->featureCategorysScheduledForDeletion = unserialize(serialize($featureCategorysToDelete));
1904:
1905: foreach ($featureCategorysToDelete as $featureCategoryRemoved) {
1906: $featureCategoryRemoved->setFeature(null);
1907: }
1908:
1909: $this->collFeatureCategorys = null;
1910: foreach ($featureCategorys as $featureCategory) {
1911: $this->addFeatureCategory($featureCategory);
1912: }
1913:
1914: $this->collFeatureCategorys = $featureCategorys;
1915: $this->collFeatureCategorysPartial = false;
1916:
1917: return $this;
1918: }
1919:
1920: 1921: 1922: 1923: 1924: 1925: 1926: 1927: 1928:
1929: public function countFeatureCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1930: {
1931: $partial = $this->collFeatureCategorysPartial && !$this->isNew();
1932: if (null === $this->collFeatureCategorys || null !== $criteria || $partial) {
1933: if ($this->isNew() && null === $this->collFeatureCategorys) {
1934: return 0;
1935: }
1936:
1937: if($partial && !$criteria) {
1938: return count($this->getFeatureCategorys());
1939: }
1940: $query = FeatureCategoryQuery::create(null, $criteria);
1941: if ($distinct) {
1942: $query->distinct();
1943: }
1944:
1945: return $query
1946: ->filterByFeature($this)
1947: ->count($con);
1948: }
1949:
1950: return count($this->collFeatureCategorys);
1951: }
1952:
1953: 1954: 1955: 1956: 1957: 1958: 1959:
1960: public function addFeatureCategory(FeatureCategory $l)
1961: {
1962: if ($this->collFeatureCategorys === null) {
1963: $this->initFeatureCategorys();
1964: $this->collFeatureCategorysPartial = true;
1965: }
1966: if (!in_array($l, $this->collFeatureCategorys->getArrayCopy(), true)) {
1967: $this->doAddFeatureCategory($l);
1968: }
1969:
1970: return $this;
1971: }
1972:
1973: 1974: 1975:
1976: protected function doAddFeatureCategory($featureCategory)
1977: {
1978: $this->collFeatureCategorys[]= $featureCategory;
1979: $featureCategory->setFeature($this);
1980: }
1981:
1982: 1983: 1984: 1985:
1986: public function removeFeatureCategory($featureCategory)
1987: {
1988: if ($this->getFeatureCategorys()->contains($featureCategory)) {
1989: $this->collFeatureCategorys->remove($this->collFeatureCategorys->search($featureCategory));
1990: if (null === $this->featureCategorysScheduledForDeletion) {
1991: $this->featureCategorysScheduledForDeletion = clone $this->collFeatureCategorys;
1992: $this->featureCategorysScheduledForDeletion->clear();
1993: }
1994: $this->featureCategorysScheduledForDeletion[]= clone $featureCategory;
1995: $featureCategory->setFeature(null);
1996: }
1997:
1998: return $this;
1999: }
2000:
2001:
2002: 2003: 2004: 2005: 2006: 2007: 2008: 2009: 2010: 2011: 2012: 2013: 2014: 2015: 2016: 2017:
2018: public function getFeatureCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2019: {
2020: $query = FeatureCategoryQuery::create(null, $criteria);
2021: $query->joinWith('Category', $join_behavior);
2022:
2023: return $this->getFeatureCategorys($query, $con);
2024: }
2025:
2026: 2027: 2028: 2029: 2030: 2031: 2032: 2033: 2034:
2035: public function clearFeatureI18ns()
2036: {
2037: $this->collFeatureI18ns = null;
2038: $this->collFeatureI18nsPartial = null;
2039:
2040: return $this;
2041: }
2042:
2043: 2044: 2045: 2046: 2047:
2048: public function resetPartialFeatureI18ns($v = true)
2049: {
2050: $this->collFeatureI18nsPartial = $v;
2051: }
2052:
2053: 2054: 2055: 2056: 2057: 2058: 2059: 2060: 2061: 2062: 2063: 2064:
2065: public function initFeatureI18ns($overrideExisting = true)
2066: {
2067: if (null !== $this->collFeatureI18ns && !$overrideExisting) {
2068: return;
2069: }
2070: $this->collFeatureI18ns = new PropelObjectCollection();
2071: $this->collFeatureI18ns->setModel('FeatureI18n');
2072: }
2073:
2074: 2075: 2076: 2077: 2078: 2079: 2080: 2081: 2082: 2083: 2084: 2085: 2086: 2087:
2088: public function getFeatureI18ns($criteria = null, PropelPDO $con = null)
2089: {
2090: $partial = $this->collFeatureI18nsPartial && !$this->isNew();
2091: if (null === $this->collFeatureI18ns || null !== $criteria || $partial) {
2092: if ($this->isNew() && null === $this->collFeatureI18ns) {
2093:
2094: $this->initFeatureI18ns();
2095: } else {
2096: $collFeatureI18ns = FeatureI18nQuery::create(null, $criteria)
2097: ->filterByFeature($this)
2098: ->find($con);
2099: if (null !== $criteria) {
2100: if (false !== $this->collFeatureI18nsPartial && count($collFeatureI18ns)) {
2101: $this->initFeatureI18ns(false);
2102:
2103: foreach($collFeatureI18ns as $obj) {
2104: if (false == $this->collFeatureI18ns->contains($obj)) {
2105: $this->collFeatureI18ns->append($obj);
2106: }
2107: }
2108:
2109: $this->collFeatureI18nsPartial = true;
2110: }
2111:
2112: $collFeatureI18ns->getInternalIterator()->rewind();
2113: return $collFeatureI18ns;
2114: }
2115:
2116: if($partial && $this->collFeatureI18ns) {
2117: foreach($this->collFeatureI18ns as $obj) {
2118: if($obj->isNew()) {
2119: $collFeatureI18ns[] = $obj;
2120: }
2121: }
2122: }
2123:
2124: $this->collFeatureI18ns = $collFeatureI18ns;
2125: $this->collFeatureI18nsPartial = false;
2126: }
2127: }
2128:
2129: return $this->collFeatureI18ns;
2130: }
2131:
2132: 2133: 2134: 2135: 2136: 2137: 2138: 2139: 2140: 2141:
2142: public function setFeatureI18ns(PropelCollection $featureI18ns, PropelPDO $con = null)
2143: {
2144: $featureI18nsToDelete = $this->getFeatureI18ns(new Criteria(), $con)->diff($featureI18ns);
2145:
2146: $this->featureI18nsScheduledForDeletion = unserialize(serialize($featureI18nsToDelete));
2147:
2148: foreach ($featureI18nsToDelete as $featureI18nRemoved) {
2149: $featureI18nRemoved->setFeature(null);
2150: }
2151:
2152: $this->collFeatureI18ns = null;
2153: foreach ($featureI18ns as $featureI18n) {
2154: $this->addFeatureI18n($featureI18n);
2155: }
2156:
2157: $this->collFeatureI18ns = $featureI18ns;
2158: $this->collFeatureI18nsPartial = false;
2159:
2160: return $this;
2161: }
2162:
2163: 2164: 2165: 2166: 2167: 2168: 2169: 2170: 2171:
2172: public function countFeatureI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2173: {
2174: $partial = $this->collFeatureI18nsPartial && !$this->isNew();
2175: if (null === $this->collFeatureI18ns || null !== $criteria || $partial) {
2176: if ($this->isNew() && null === $this->collFeatureI18ns) {
2177: return 0;
2178: }
2179:
2180: if($partial && !$criteria) {
2181: return count($this->getFeatureI18ns());
2182: }
2183: $query = FeatureI18nQuery::create(null, $criteria);
2184: if ($distinct) {
2185: $query->distinct();
2186: }
2187:
2188: return $query
2189: ->filterByFeature($this)
2190: ->count($con);
2191: }
2192:
2193: return count($this->collFeatureI18ns);
2194: }
2195:
2196: 2197: 2198: 2199: 2200: 2201: 2202:
2203: public function addFeatureI18n(FeatureI18n $l)
2204: {
2205: if ($l && $locale = $l->getLocale()) {
2206: $this->setLocale($locale);
2207: $this->currentTranslations[$locale] = $l;
2208: }
2209: if ($this->collFeatureI18ns === null) {
2210: $this->initFeatureI18ns();
2211: $this->collFeatureI18nsPartial = true;
2212: }
2213: if (!in_array($l, $this->collFeatureI18ns->getArrayCopy(), true)) {
2214: $this->doAddFeatureI18n($l);
2215: }
2216:
2217: return $this;
2218: }
2219:
2220: 2221: 2222:
2223: protected function doAddFeatureI18n($featureI18n)
2224: {
2225: $this->collFeatureI18ns[]= $featureI18n;
2226: $featureI18n->setFeature($this);
2227: }
2228:
2229: 2230: 2231: 2232:
2233: public function removeFeatureI18n($featureI18n)
2234: {
2235: if ($this->getFeatureI18ns()->contains($featureI18n)) {
2236: $this->collFeatureI18ns->remove($this->collFeatureI18ns->search($featureI18n));
2237: if (null === $this->featureI18nsScheduledForDeletion) {
2238: $this->featureI18nsScheduledForDeletion = clone $this->collFeatureI18ns;
2239: $this->featureI18nsScheduledForDeletion->clear();
2240: }
2241: $this->featureI18nsScheduledForDeletion[]= clone $featureI18n;
2242: $featureI18n->setFeature(null);
2243: }
2244:
2245: return $this;
2246: }
2247:
2248: 2249: 2250:
2251: public function clear()
2252: {
2253: $this->id = null;
2254: $this->visible = null;
2255: $this->position = null;
2256: $this->created_at = null;
2257: $this->updated_at = null;
2258: $this->alreadyInSave = false;
2259: $this->alreadyInValidation = false;
2260: $this->alreadyInClearAllReferencesDeep = false;
2261: $this->clearAllReferences();
2262: $this->applyDefaultValues();
2263: $this->resetModified();
2264: $this->setNew(true);
2265: $this->setDeleted(false);
2266: }
2267:
2268: 2269: 2270: 2271: 2272: 2273: 2274: 2275: 2276:
2277: public function clearAllReferences($deep = false)
2278: {
2279: if ($deep && !$this->alreadyInClearAllReferencesDeep) {
2280: $this->alreadyInClearAllReferencesDeep = true;
2281: if ($this->collFeatureAvs) {
2282: foreach ($this->collFeatureAvs as $o) {
2283: $o->clearAllReferences($deep);
2284: }
2285: }
2286: if ($this->collFeatureProds) {
2287: foreach ($this->collFeatureProds as $o) {
2288: $o->clearAllReferences($deep);
2289: }
2290: }
2291: if ($this->collFeatureCategorys) {
2292: foreach ($this->collFeatureCategorys as $o) {
2293: $o->clearAllReferences($deep);
2294: }
2295: }
2296: if ($this->collFeatureI18ns) {
2297: foreach ($this->collFeatureI18ns as $o) {
2298: $o->clearAllReferences($deep);
2299: }
2300: }
2301:
2302: $this->alreadyInClearAllReferencesDeep = false;
2303: }
2304:
2305:
2306: $this->currentLocale = 'en_US';
2307: $this->currentTranslations = null;
2308:
2309: if ($this->collFeatureAvs instanceof PropelCollection) {
2310: $this->collFeatureAvs->clearIterator();
2311: }
2312: $this->collFeatureAvs = null;
2313: if ($this->collFeatureProds instanceof PropelCollection) {
2314: $this->collFeatureProds->clearIterator();
2315: }
2316: $this->collFeatureProds = null;
2317: if ($this->collFeatureCategorys instanceof PropelCollection) {
2318: $this->collFeatureCategorys->clearIterator();
2319: }
2320: $this->collFeatureCategorys = null;
2321: if ($this->collFeatureI18ns instanceof PropelCollection) {
2322: $this->collFeatureI18ns->clearIterator();
2323: }
2324: $this->collFeatureI18ns = null;
2325: }
2326:
2327: 2328: 2329: 2330: 2331:
2332: public function __toString()
2333: {
2334: return (string) $this->exportTo(FeaturePeer::DEFAULT_STRING_FORMAT);
2335: }
2336:
2337: 2338: 2339: 2340: 2341:
2342: public function isAlreadyInSave()
2343: {
2344: return $this->alreadyInSave;
2345: }
2346:
2347:
2348:
2349: 2350: 2351: 2352: 2353:
2354: public function keepUpdateDateUnchanged()
2355: {
2356: $this->modifiedColumns[] = FeaturePeer::UPDATED_AT;
2357:
2358: return $this;
2359: }
2360:
2361:
2362:
2363: 2364: 2365: 2366: 2367: 2368: 2369:
2370: public function setLocale($locale = 'en_US')
2371: {
2372: $this->currentLocale = $locale;
2373:
2374: return $this;
2375: }
2376:
2377: 2378: 2379: 2380: 2381:
2382: public function getLocale()
2383: {
2384: return $this->currentLocale;
2385: }
2386:
2387: 2388: 2389: 2390: 2391: 2392: 2393:
2394: public function getTranslation($locale = 'en_US', PropelPDO $con = null)
2395: {
2396: if (!isset($this->currentTranslations[$locale])) {
2397: if (null !== $this->collFeatureI18ns) {
2398: foreach ($this->collFeatureI18ns as $translation) {
2399: if ($translation->getLocale() == $locale) {
2400: $this->currentTranslations[$locale] = $translation;
2401:
2402: return $translation;
2403: }
2404: }
2405: }
2406: if ($this->isNew()) {
2407: $translation = new FeatureI18n();
2408: $translation->setLocale($locale);
2409: } else {
2410: $translation = FeatureI18nQuery::create()
2411: ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
2412: ->findOneOrCreate($con);
2413: $this->currentTranslations[$locale] = $translation;
2414: }
2415: $this->addFeatureI18n($translation);
2416: }
2417:
2418: return $this->currentTranslations[$locale];
2419: }
2420:
2421: 2422: 2423: 2424: 2425: 2426: 2427: 2428:
2429: public function removeTranslation($locale = 'en_US', PropelPDO $con = null)
2430: {
2431: if (!$this->isNew()) {
2432: FeatureI18nQuery::create()
2433: ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
2434: ->delete($con);
2435: }
2436: if (isset($this->currentTranslations[$locale])) {
2437: unset($this->currentTranslations[$locale]);
2438: }
2439: foreach ($this->collFeatureI18ns as $key => $translation) {
2440: if ($translation->getLocale() == $locale) {
2441: unset($this->collFeatureI18ns[$key]);
2442: break;
2443: }
2444: }
2445:
2446: return $this;
2447: }
2448:
2449: 2450: 2451: 2452: 2453: 2454:
2455: public function getCurrentTranslation(PropelPDO $con = null)
2456: {
2457: return $this->getTranslation($this->getLocale(), $con);
2458: }
2459:
2460:
2461: 2462: 2463: 2464: 2465:
2466: public function getTitle()
2467: {
2468: return $this->getCurrentTranslation()->getTitle();
2469: }
2470:
2471:
2472: 2473: 2474: 2475: 2476: 2477:
2478: public function setTitle($v)
2479: { $this->getCurrentTranslation()->setTitle($v);
2480:
2481: return $this;
2482: }
2483:
2484:
2485: 2486: 2487: 2488: 2489:
2490: public function getDescription()
2491: {
2492: return $this->getCurrentTranslation()->getDescription();
2493: }
2494:
2495:
2496: 2497: 2498: 2499: 2500: 2501:
2502: public function setDescription($v)
2503: { $this->getCurrentTranslation()->setDescription($v);
2504:
2505: return $this;
2506: }
2507:
2508:
2509: 2510: 2511: 2512: 2513:
2514: public function getChapo()
2515: {
2516: return $this->getCurrentTranslation()->getChapo();
2517: }
2518:
2519:
2520: 2521: 2522: 2523: 2524: 2525:
2526: public function setChapo($v)
2527: { $this->getCurrentTranslation()->setChapo($v);
2528:
2529: return $this;
2530: }
2531:
2532:
2533: 2534: 2535: 2536: 2537:
2538: public function getPostscriptum()
2539: {
2540: return $this->getCurrentTranslation()->getPostscriptum();
2541: }
2542:
2543:
2544: 2545: 2546: 2547: 2548: 2549:
2550: public function setPostscriptum($v)
2551: { $this->getCurrentTranslation()->setPostscriptum($v);
2552:
2553: return $this;
2554: }
2555:
2556: }
2557: