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\AttributeCategory;
19: use Thelia\Model\AttributeCategoryQuery;
20: use Thelia\Model\Category;
21: use Thelia\Model\CategoryI18n;
22: use Thelia\Model\CategoryI18nQuery;
23: use Thelia\Model\CategoryPeer;
24: use Thelia\Model\CategoryQuery;
25: use Thelia\Model\CategoryVersion;
26: use Thelia\Model\CategoryVersionPeer;
27: use Thelia\Model\CategoryVersionQuery;
28: use Thelia\Model\ContentAssoc;
29: use Thelia\Model\ContentAssocQuery;
30: use Thelia\Model\Document;
31: use Thelia\Model\DocumentQuery;
32: use Thelia\Model\FeatureCategory;
33: use Thelia\Model\FeatureCategoryQuery;
34: use Thelia\Model\Image;
35: use Thelia\Model\ImageQuery;
36: use Thelia\Model\ProductCategory;
37: use Thelia\Model\ProductCategoryQuery;
38: use Thelia\Model\Rewriting;
39: use Thelia\Model\RewritingQuery;
40:
41: 42: 43: 44: 45: 46: 47:
48: abstract class BaseCategory extends BaseObject implements Persistent
49: {
50: 51: 52:
53: const PEER = 'Thelia\\Model\\CategoryPeer';
54:
55: 56: 57: 58: 59: 60:
61: protected static $peer;
62:
63: 64: 65: 66:
67: protected $startCopy = false;
68:
69: 70: 71: 72:
73: protected $id;
74:
75: 76: 77: 78:
79: protected $parent;
80:
81: 82: 83: 84:
85: protected $link;
86:
87: 88: 89: 90:
91: protected $visible;
92:
93: 94: 95: 96:
97: protected $position;
98:
99: 100: 101: 102:
103: protected $created_at;
104:
105: 106: 107: 108:
109: protected $updated_at;
110:
111: 112: 113: 114: 115:
116: protected $version;
117:
118: 119: 120: 121:
122: protected $version_created_at;
123:
124: 125: 126: 127:
128: protected $version_created_by;
129:
130: 131: 132:
133: protected $collProductCategorys;
134: protected $collProductCategorysPartial;
135:
136: 137: 138:
139: protected $collFeatureCategorys;
140: protected $collFeatureCategorysPartial;
141:
142: 143: 144:
145: protected $collAttributeCategorys;
146: protected $collAttributeCategorysPartial;
147:
148: 149: 150:
151: protected $collContentAssocs;
152: protected $collContentAssocsPartial;
153:
154: 155: 156:
157: protected $collImages;
158: protected $collImagesPartial;
159:
160: 161: 162:
163: protected $collDocuments;
164: protected $collDocumentsPartial;
165:
166: 167: 168:
169: protected $collRewritings;
170: protected $collRewritingsPartial;
171:
172: 173: 174:
175: protected $collCategoryI18ns;
176: protected $collCategoryI18nsPartial;
177:
178: 179: 180:
181: protected $collCategoryVersions;
182: protected $collCategoryVersionsPartial;
183:
184: 185: 186: 187: 188:
189: protected $alreadyInSave = false;
190:
191: 192: 193: 194: 195:
196: protected $alreadyInValidation = false;
197:
198: 199: 200: 201:
202: protected $alreadyInClearAllReferencesDeep = false;
203:
204:
205:
206: 207: 208: 209:
210: protected $currentLocale = 'en_US';
211:
212: 213: 214: 215:
216: protected $currentTranslations;
217:
218:
219:
220:
221: 222: 223:
224: protected $enforceVersion = false;
225:
226: 227: 228: 229:
230: protected $productCategorysScheduledForDeletion = null;
231:
232: 233: 234: 235:
236: protected $featureCategorysScheduledForDeletion = null;
237:
238: 239: 240: 241:
242: protected $attributeCategorysScheduledForDeletion = null;
243:
244: 245: 246: 247:
248: protected $contentAssocsScheduledForDeletion = null;
249:
250: 251: 252: 253:
254: protected $imagesScheduledForDeletion = null;
255:
256: 257: 258: 259:
260: protected $documentsScheduledForDeletion = null;
261:
262: 263: 264: 265:
266: protected $rewritingsScheduledForDeletion = null;
267:
268: 269: 270: 271:
272: protected $categoryI18nsScheduledForDeletion = null;
273:
274: 275: 276: 277:
278: protected $categoryVersionsScheduledForDeletion = null;
279:
280: 281: 282: 283: 284: 285:
286: public function applyDefaultValues()
287: {
288: $this->version = 0;
289: }
290:
291: 292: 293: 294:
295: public function __construct()
296: {
297: parent::__construct();
298: $this->applyDefaultValues();
299: }
300:
301: 302: 303: 304: 305:
306: public function getId()
307: {
308: return $this->id;
309: }
310:
311: 312: 313: 314: 315:
316: public function getParent()
317: {
318: return $this->parent;
319: }
320:
321: 322: 323: 324: 325:
326: public function getLink()
327: {
328: return $this->link;
329: }
330:
331: 332: 333: 334: 335:
336: public function getVisible()
337: {
338: return $this->visible;
339: }
340:
341: 342: 343: 344: 345:
346: public function getPosition()
347: {
348: return $this->position;
349: }
350:
351: 352: 353: 354: 355: 356: 357: 358: 359:
360: public function getCreatedAt($format = 'Y-m-d H:i:s')
361: {
362: if ($this->created_at === null) {
363: return null;
364: }
365:
366: if ($this->created_at === '0000-00-00 00:00:00') {
367:
368:
369: return null;
370: }
371:
372: try {
373: $dt = new DateTime($this->created_at);
374: } catch (Exception $x) {
375: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
376: }
377:
378: if ($format === null) {
379:
380: return $dt;
381: }
382:
383: if (strpos($format, '%') !== false) {
384: return strftime($format, $dt->format('U'));
385: }
386:
387: return $dt->format($format);
388:
389: }
390:
391: 392: 393: 394: 395: 396: 397: 398: 399:
400: public function getUpdatedAt($format = 'Y-m-d H:i:s')
401: {
402: if ($this->updated_at === null) {
403: return null;
404: }
405:
406: if ($this->updated_at === '0000-00-00 00:00:00') {
407:
408:
409: return null;
410: }
411:
412: try {
413: $dt = new DateTime($this->updated_at);
414: } catch (Exception $x) {
415: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
416: }
417:
418: if ($format === null) {
419:
420: return $dt;
421: }
422:
423: if (strpos($format, '%') !== false) {
424: return strftime($format, $dt->format('U'));
425: }
426:
427: return $dt->format($format);
428:
429: }
430:
431: 432: 433: 434: 435:
436: public function getVersion()
437: {
438: return $this->version;
439: }
440:
441: 442: 443: 444: 445: 446: 447: 448: 449:
450: public function getVersionCreatedAt($format = 'Y-m-d H:i:s')
451: {
452: if ($this->version_created_at === null) {
453: return null;
454: }
455:
456: if ($this->version_created_at === '0000-00-00 00:00:00') {
457:
458:
459: return null;
460: }
461:
462: try {
463: $dt = new DateTime($this->version_created_at);
464: } catch (Exception $x) {
465: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
466: }
467:
468: if ($format === null) {
469:
470: return $dt;
471: }
472:
473: if (strpos($format, '%') !== false) {
474: return strftime($format, $dt->format('U'));
475: }
476:
477: return $dt->format($format);
478:
479: }
480:
481: 482: 483: 484: 485:
486: public function getVersionCreatedBy()
487: {
488: return $this->version_created_by;
489: }
490:
491: 492: 493: 494: 495: 496:
497: public function setId($v)
498: {
499: if ($v !== null && is_numeric($v)) {
500: $v = (int) $v;
501: }
502:
503: if ($this->id !== $v) {
504: $this->id = $v;
505: $this->modifiedColumns[] = CategoryPeer::ID;
506: }
507:
508:
509: return $this;
510: }
511:
512: 513: 514: 515: 516: 517:
518: public function setParent($v)
519: {
520: if ($v !== null && is_numeric($v)) {
521: $v = (int) $v;
522: }
523:
524: if ($this->parent !== $v) {
525: $this->parent = $v;
526: $this->modifiedColumns[] = CategoryPeer::PARENT;
527: }
528:
529:
530: return $this;
531: }
532:
533: 534: 535: 536: 537: 538:
539: public function setLink($v)
540: {
541: if ($v !== null && is_numeric($v)) {
542: $v = (string) $v;
543: }
544:
545: if ($this->link !== $v) {
546: $this->link = $v;
547: $this->modifiedColumns[] = CategoryPeer::LINK;
548: }
549:
550:
551: return $this;
552: }
553:
554: 555: 556: 557: 558: 559:
560: public function setVisible($v)
561: {
562: if ($v !== null && is_numeric($v)) {
563: $v = (int) $v;
564: }
565:
566: if ($this->visible !== $v) {
567: $this->visible = $v;
568: $this->modifiedColumns[] = CategoryPeer::VISIBLE;
569: }
570:
571:
572: return $this;
573: }
574:
575: 576: 577: 578: 579: 580:
581: public function setPosition($v)
582: {
583: if ($v !== null && is_numeric($v)) {
584: $v = (int) $v;
585: }
586:
587: if ($this->position !== $v) {
588: $this->position = $v;
589: $this->modifiedColumns[] = CategoryPeer::POSITION;
590: }
591:
592:
593: return $this;
594: }
595:
596: 597: 598: 599: 600: 601: 602:
603: public function setCreatedAt($v)
604: {
605: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
606: if ($this->created_at !== null || $dt !== null) {
607: $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
608: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
609: if ($currentDateAsString !== $newDateAsString) {
610: $this->created_at = $newDateAsString;
611: $this->modifiedColumns[] = CategoryPeer::CREATED_AT;
612: }
613: }
614:
615:
616: return $this;
617: }
618:
619: 620: 621: 622: 623: 624: 625:
626: public function setUpdatedAt($v)
627: {
628: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
629: if ($this->updated_at !== null || $dt !== null) {
630: $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
631: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
632: if ($currentDateAsString !== $newDateAsString) {
633: $this->updated_at = $newDateAsString;
634: $this->modifiedColumns[] = CategoryPeer::UPDATED_AT;
635: }
636: }
637:
638:
639: return $this;
640: }
641:
642: 643: 644: 645: 646: 647:
648: public function setVersion($v)
649: {
650: if ($v !== null && is_numeric($v)) {
651: $v = (int) $v;
652: }
653:
654: if ($this->version !== $v) {
655: $this->version = $v;
656: $this->modifiedColumns[] = CategoryPeer::VERSION;
657: }
658:
659:
660: return $this;
661: }
662:
663: 664: 665: 666: 667: 668: 669:
670: public function setVersionCreatedAt($v)
671: {
672: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
673: if ($this->version_created_at !== null || $dt !== null) {
674: $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
675: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
676: if ($currentDateAsString !== $newDateAsString) {
677: $this->version_created_at = $newDateAsString;
678: $this->modifiedColumns[] = CategoryPeer::VERSION_CREATED_AT;
679: }
680: }
681:
682:
683: return $this;
684: }
685:
686: 687: 688: 689: 690: 691:
692: public function setVersionCreatedBy($v)
693: {
694: if ($v !== null && is_numeric($v)) {
695: $v = (string) $v;
696: }
697:
698: if ($this->version_created_by !== $v) {
699: $this->version_created_by = $v;
700: $this->modifiedColumns[] = CategoryPeer::VERSION_CREATED_BY;
701: }
702:
703:
704: return $this;
705: }
706:
707: 708: 709: 710: 711: 712: 713: 714:
715: public function hasOnlyDefaultValues()
716: {
717: if ($this->version !== 0) {
718: return false;
719: }
720:
721:
722: return true;
723: }
724:
725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738:
739: public function hydrate($row, $startcol = 0, $rehydrate = false)
740: {
741: try {
742:
743: $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
744: $this->parent = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
745: $this->link = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
746: $this->visible = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
747: $this->position = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
748: $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
749: $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
750: $this->version = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
751: $this->version_created_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
752: $this->version_created_by = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
753: $this->resetModified();
754:
755: $this->setNew(false);
756:
757: if ($rehydrate) {
758: $this->ensureConsistency();
759: }
760: $this->postHydrate($row, $startcol, $rehydrate);
761: return $startcol + 10;
762:
763: } catch (Exception $e) {
764: throw new PropelException("Error populating Category object", $e);
765: }
766: }
767:
768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780:
781: public function ensureConsistency()
782: {
783:
784: }
785:
786: 787: 788: 789: 790: 791: 792: 793: 794: 795:
796: public function reload($deep = false, PropelPDO $con = null)
797: {
798: if ($this->isDeleted()) {
799: throw new PropelException("Cannot reload a deleted object.");
800: }
801:
802: if ($this->isNew()) {
803: throw new PropelException("Cannot reload an unsaved object.");
804: }
805:
806: if ($con === null) {
807: $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
808: }
809:
810:
811:
812:
813: $stmt = CategoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
814: $row = $stmt->fetch(PDO::FETCH_NUM);
815: $stmt->closeCursor();
816: if (!$row) {
817: throw new PropelException('Cannot find matching row in the database to reload object values.');
818: }
819: $this->hydrate($row, 0, true);
820:
821: if ($deep) {
822:
823: $this->collProductCategorys = null;
824:
825: $this->collFeatureCategorys = null;
826:
827: $this->collAttributeCategorys = null;
828:
829: $this->collContentAssocs = null;
830:
831: $this->collImages = null;
832:
833: $this->collDocuments = null;
834:
835: $this->collRewritings = null;
836:
837: $this->collCategoryI18ns = null;
838:
839: $this->collCategoryVersions = null;
840:
841: }
842: }
843:
844: 845: 846: 847: 848: 849: 850: 851: 852: 853:
854: public function delete(PropelPDO $con = null)
855: {
856: if ($this->isDeleted()) {
857: throw new PropelException("This object has already been deleted.");
858: }
859:
860: if ($con === null) {
861: $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
862: }
863:
864: $con->beginTransaction();
865: try {
866: $deleteQuery = CategoryQuery::create()
867: ->filterByPrimaryKey($this->getPrimaryKey());
868: $ret = $this->preDelete($con);
869: if ($ret) {
870: $deleteQuery->delete($con);
871: $this->postDelete($con);
872: $con->commit();
873: $this->setDeleted(true);
874: } else {
875: $con->commit();
876: }
877: } catch (Exception $e) {
878: $con->rollBack();
879: throw $e;
880: }
881: }
882:
883: 884: 885: 886: 887: 888: 889: 890: 891: 892: 893: 894: 895: 896:
897: public function save(PropelPDO $con = null)
898: {
899: if ($this->isDeleted()) {
900: throw new PropelException("You cannot save an object that has been deleted.");
901: }
902:
903: if ($con === null) {
904: $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
905: }
906:
907: $con->beginTransaction();
908: $isInsert = $this->isNew();
909: try {
910: $ret = $this->preSave($con);
911:
912: if ($this->isVersioningNecessary()) {
913: $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
914: if (!$this->isColumnModified(CategoryPeer::VERSION_CREATED_AT)) {
915: $this->setVersionCreatedAt(time());
916: }
917: $createVersion = true;
918: }
919: if ($isInsert) {
920: $ret = $ret && $this->preInsert($con);
921:
922: if (!$this->isColumnModified(CategoryPeer::CREATED_AT)) {
923: $this->setCreatedAt(time());
924: }
925: if (!$this->isColumnModified(CategoryPeer::UPDATED_AT)) {
926: $this->setUpdatedAt(time());
927: }
928: } else {
929: $ret = $ret && $this->preUpdate($con);
930:
931: if ($this->isModified() && !$this->isColumnModified(CategoryPeer::UPDATED_AT)) {
932: $this->setUpdatedAt(time());
933: }
934: }
935: if ($ret) {
936: $affectedRows = $this->doSave($con);
937: if ($isInsert) {
938: $this->postInsert($con);
939: } else {
940: $this->postUpdate($con);
941: }
942: $this->postSave($con);
943:
944: if (isset($createVersion)) {
945: $this->addVersion($con);
946: }
947: CategoryPeer::addInstanceToPool($this);
948: } else {
949: $affectedRows = 0;
950: }
951: $con->commit();
952:
953: return $affectedRows;
954: } catch (Exception $e) {
955: $con->rollBack();
956: throw $e;
957: }
958: }
959:
960: 961: 962: 963: 964: 965: 966: 967: 968: 969: 970:
971: protected function doSave(PropelPDO $con)
972: {
973: $affectedRows = 0;
974: if (!$this->alreadyInSave) {
975: $this->alreadyInSave = true;
976:
977: if ($this->isNew() || $this->isModified()) {
978:
979: if ($this->isNew()) {
980: $this->doInsert($con);
981: } else {
982: $this->doUpdate($con);
983: }
984: $affectedRows += 1;
985: $this->resetModified();
986: }
987:
988: if ($this->productCategorysScheduledForDeletion !== null) {
989: if (!$this->productCategorysScheduledForDeletion->isEmpty()) {
990: ProductCategoryQuery::create()
991: ->filterByPrimaryKeys($this->productCategorysScheduledForDeletion->getPrimaryKeys(false))
992: ->delete($con);
993: $this->productCategorysScheduledForDeletion = null;
994: }
995: }
996:
997: if ($this->collProductCategorys !== null) {
998: foreach ($this->collProductCategorys as $referrerFK) {
999: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1000: $affectedRows += $referrerFK->save($con);
1001: }
1002: }
1003: }
1004:
1005: if ($this->featureCategorysScheduledForDeletion !== null) {
1006: if (!$this->featureCategorysScheduledForDeletion->isEmpty()) {
1007: FeatureCategoryQuery::create()
1008: ->filterByPrimaryKeys($this->featureCategorysScheduledForDeletion->getPrimaryKeys(false))
1009: ->delete($con);
1010: $this->featureCategorysScheduledForDeletion = null;
1011: }
1012: }
1013:
1014: if ($this->collFeatureCategorys !== null) {
1015: foreach ($this->collFeatureCategorys as $referrerFK) {
1016: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1017: $affectedRows += $referrerFK->save($con);
1018: }
1019: }
1020: }
1021:
1022: if ($this->attributeCategorysScheduledForDeletion !== null) {
1023: if (!$this->attributeCategorysScheduledForDeletion->isEmpty()) {
1024: AttributeCategoryQuery::create()
1025: ->filterByPrimaryKeys($this->attributeCategorysScheduledForDeletion->getPrimaryKeys(false))
1026: ->delete($con);
1027: $this->attributeCategorysScheduledForDeletion = null;
1028: }
1029: }
1030:
1031: if ($this->collAttributeCategorys !== null) {
1032: foreach ($this->collAttributeCategorys as $referrerFK) {
1033: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1034: $affectedRows += $referrerFK->save($con);
1035: }
1036: }
1037: }
1038:
1039: if ($this->contentAssocsScheduledForDeletion !== null) {
1040: if (!$this->contentAssocsScheduledForDeletion->isEmpty()) {
1041: foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) {
1042:
1043: $contentAssoc->save($con);
1044: }
1045: $this->contentAssocsScheduledForDeletion = null;
1046: }
1047: }
1048:
1049: if ($this->collContentAssocs !== null) {
1050: foreach ($this->collContentAssocs as $referrerFK) {
1051: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1052: $affectedRows += $referrerFK->save($con);
1053: }
1054: }
1055: }
1056:
1057: if ($this->imagesScheduledForDeletion !== null) {
1058: if (!$this->imagesScheduledForDeletion->isEmpty()) {
1059: foreach ($this->imagesScheduledForDeletion as $image) {
1060:
1061: $image->save($con);
1062: }
1063: $this->imagesScheduledForDeletion = null;
1064: }
1065: }
1066:
1067: if ($this->collImages !== null) {
1068: foreach ($this->collImages as $referrerFK) {
1069: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1070: $affectedRows += $referrerFK->save($con);
1071: }
1072: }
1073: }
1074:
1075: if ($this->documentsScheduledForDeletion !== null) {
1076: if (!$this->documentsScheduledForDeletion->isEmpty()) {
1077: foreach ($this->documentsScheduledForDeletion as $document) {
1078:
1079: $document->save($con);
1080: }
1081: $this->documentsScheduledForDeletion = null;
1082: }
1083: }
1084:
1085: if ($this->collDocuments !== null) {
1086: foreach ($this->collDocuments as $referrerFK) {
1087: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1088: $affectedRows += $referrerFK->save($con);
1089: }
1090: }
1091: }
1092:
1093: if ($this->rewritingsScheduledForDeletion !== null) {
1094: if (!$this->rewritingsScheduledForDeletion->isEmpty()) {
1095: foreach ($this->rewritingsScheduledForDeletion as $rewriting) {
1096:
1097: $rewriting->save($con);
1098: }
1099: $this->rewritingsScheduledForDeletion = null;
1100: }
1101: }
1102:
1103: if ($this->collRewritings !== null) {
1104: foreach ($this->collRewritings as $referrerFK) {
1105: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1106: $affectedRows += $referrerFK->save($con);
1107: }
1108: }
1109: }
1110:
1111: if ($this->categoryI18nsScheduledForDeletion !== null) {
1112: if (!$this->categoryI18nsScheduledForDeletion->isEmpty()) {
1113: CategoryI18nQuery::create()
1114: ->filterByPrimaryKeys($this->categoryI18nsScheduledForDeletion->getPrimaryKeys(false))
1115: ->delete($con);
1116: $this->categoryI18nsScheduledForDeletion = null;
1117: }
1118: }
1119:
1120: if ($this->collCategoryI18ns !== null) {
1121: foreach ($this->collCategoryI18ns as $referrerFK) {
1122: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1123: $affectedRows += $referrerFK->save($con);
1124: }
1125: }
1126: }
1127:
1128: if ($this->categoryVersionsScheduledForDeletion !== null) {
1129: if (!$this->categoryVersionsScheduledForDeletion->isEmpty()) {
1130: CategoryVersionQuery::create()
1131: ->filterByPrimaryKeys($this->categoryVersionsScheduledForDeletion->getPrimaryKeys(false))
1132: ->delete($con);
1133: $this->categoryVersionsScheduledForDeletion = null;
1134: }
1135: }
1136:
1137: if ($this->collCategoryVersions !== null) {
1138: foreach ($this->collCategoryVersions as $referrerFK) {
1139: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1140: $affectedRows += $referrerFK->save($con);
1141: }
1142: }
1143: }
1144:
1145: $this->alreadyInSave = false;
1146:
1147: }
1148:
1149: return $affectedRows;
1150: }
1151:
1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159:
1160: protected function doInsert(PropelPDO $con)
1161: {
1162: $modifiedColumns = array();
1163: $index = 0;
1164:
1165: $this->modifiedColumns[] = CategoryPeer::ID;
1166: if (null !== $this->id) {
1167: throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryPeer::ID . ')');
1168: }
1169:
1170:
1171: if ($this->isColumnModified(CategoryPeer::ID)) {
1172: $modifiedColumns[':p' . $index++] = '`id`';
1173: }
1174: if ($this->isColumnModified(CategoryPeer::PARENT)) {
1175: $modifiedColumns[':p' . $index++] = '`parent`';
1176: }
1177: if ($this->isColumnModified(CategoryPeer::LINK)) {
1178: $modifiedColumns[':p' . $index++] = '`link`';
1179: }
1180: if ($this->isColumnModified(CategoryPeer::VISIBLE)) {
1181: $modifiedColumns[':p' . $index++] = '`visible`';
1182: }
1183: if ($this->isColumnModified(CategoryPeer::POSITION)) {
1184: $modifiedColumns[':p' . $index++] = '`position`';
1185: }
1186: if ($this->isColumnModified(CategoryPeer::CREATED_AT)) {
1187: $modifiedColumns[':p' . $index++] = '`created_at`';
1188: }
1189: if ($this->isColumnModified(CategoryPeer::UPDATED_AT)) {
1190: $modifiedColumns[':p' . $index++] = '`updated_at`';
1191: }
1192: if ($this->isColumnModified(CategoryPeer::VERSION)) {
1193: $modifiedColumns[':p' . $index++] = '`version`';
1194: }
1195: if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_AT)) {
1196: $modifiedColumns[':p' . $index++] = '`version_created_at`';
1197: }
1198: if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_BY)) {
1199: $modifiedColumns[':p' . $index++] = '`version_created_by`';
1200: }
1201:
1202: $sql = sprintf(
1203: 'INSERT INTO `category` (%s) VALUES (%s)',
1204: implode(', ', $modifiedColumns),
1205: implode(', ', array_keys($modifiedColumns))
1206: );
1207:
1208: try {
1209: $stmt = $con->prepare($sql);
1210: foreach ($modifiedColumns as $identifier => $columnName) {
1211: switch ($columnName) {
1212: case '`id`':
1213: $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
1214: break;
1215: case '`parent`':
1216: $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT);
1217: break;
1218: case '`link`':
1219: $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR);
1220: break;
1221: case '`visible`':
1222: $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
1223: break;
1224: case '`position`':
1225: $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
1226: break;
1227: case '`created_at`':
1228: $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
1229: break;
1230: case '`updated_at`':
1231: $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
1232: break;
1233: case '`version`':
1234: $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
1235: break;
1236: case '`version_created_at`':
1237: $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
1238: break;
1239: case '`version_created_by`':
1240: $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
1241: break;
1242: }
1243: }
1244: $stmt->execute();
1245: } catch (Exception $e) {
1246: Propel::log($e->getMessage(), Propel::LOG_ERR);
1247: throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
1248: }
1249:
1250: try {
1251: $pk = $con->lastInsertId();
1252: } catch (Exception $e) {
1253: throw new PropelException('Unable to get autoincrement id.', $e);
1254: }
1255: $this->setId($pk);
1256:
1257: $this->setNew(false);
1258: }
1259:
1260: 1261: 1262: 1263: 1264: 1265: 1266:
1267: protected function doUpdate(PropelPDO $con)
1268: {
1269: $selectCriteria = $this->buildPkeyCriteria();
1270: $valuesCriteria = $this->buildCriteria();
1271: BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
1272: }
1273:
1274: 1275: 1276: 1277:
1278: protected $validationFailures = array();
1279:
1280: 1281: 1282: 1283: 1284: 1285: 1286:
1287: public function getValidationFailures()
1288: {
1289: return $this->validationFailures;
1290: }
1291:
1292: 1293: 1294: 1295: 1296: 1297: 1298: 1299: 1300: 1301: 1302:
1303: public function validate($columns = null)
1304: {
1305: $res = $this->doValidate($columns);
1306: if ($res === true) {
1307: $this->validationFailures = array();
1308:
1309: return true;
1310: }
1311:
1312: $this->validationFailures = $res;
1313:
1314: return false;
1315: }
1316:
1317: 1318: 1319: 1320: 1321: 1322: 1323: 1324: 1325: 1326:
1327: protected function doValidate($columns = null)
1328: {
1329: if (!$this->alreadyInValidation) {
1330: $this->alreadyInValidation = true;
1331: $retval = null;
1332:
1333: $failureMap = array();
1334:
1335:
1336: if (($retval = CategoryPeer::doValidate($this, $columns)) !== true) {
1337: $failureMap = array_merge($failureMap, $retval);
1338: }
1339:
1340:
1341: if ($this->collProductCategorys !== null) {
1342: foreach ($this->collProductCategorys as $referrerFK) {
1343: if (!$referrerFK->validate($columns)) {
1344: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1345: }
1346: }
1347: }
1348:
1349: if ($this->collFeatureCategorys !== null) {
1350: foreach ($this->collFeatureCategorys as $referrerFK) {
1351: if (!$referrerFK->validate($columns)) {
1352: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1353: }
1354: }
1355: }
1356:
1357: if ($this->collAttributeCategorys !== null) {
1358: foreach ($this->collAttributeCategorys as $referrerFK) {
1359: if (!$referrerFK->validate($columns)) {
1360: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1361: }
1362: }
1363: }
1364:
1365: if ($this->collContentAssocs !== null) {
1366: foreach ($this->collContentAssocs as $referrerFK) {
1367: if (!$referrerFK->validate($columns)) {
1368: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1369: }
1370: }
1371: }
1372:
1373: if ($this->collImages !== null) {
1374: foreach ($this->collImages as $referrerFK) {
1375: if (!$referrerFK->validate($columns)) {
1376: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1377: }
1378: }
1379: }
1380:
1381: if ($this->collDocuments !== null) {
1382: foreach ($this->collDocuments as $referrerFK) {
1383: if (!$referrerFK->validate($columns)) {
1384: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1385: }
1386: }
1387: }
1388:
1389: if ($this->collRewritings !== null) {
1390: foreach ($this->collRewritings as $referrerFK) {
1391: if (!$referrerFK->validate($columns)) {
1392: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1393: }
1394: }
1395: }
1396:
1397: if ($this->collCategoryI18ns !== null) {
1398: foreach ($this->collCategoryI18ns as $referrerFK) {
1399: if (!$referrerFK->validate($columns)) {
1400: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1401: }
1402: }
1403: }
1404:
1405: if ($this->collCategoryVersions !== null) {
1406: foreach ($this->collCategoryVersions as $referrerFK) {
1407: if (!$referrerFK->validate($columns)) {
1408: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1409: }
1410: }
1411: }
1412:
1413:
1414: $this->alreadyInValidation = false;
1415: }
1416:
1417: return (!empty($failureMap) ? $failureMap : true);
1418: }
1419:
1420: 1421: 1422: 1423: 1424: 1425: 1426: 1427: 1428: 1429:
1430: public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
1431: {
1432: $pos = CategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1433: $field = $this->getByPosition($pos);
1434:
1435: return $field;
1436: }
1437:
1438: 1439: 1440: 1441: 1442: 1443: 1444:
1445: public function getByPosition($pos)
1446: {
1447: switch ($pos) {
1448: case 0:
1449: return $this->getId();
1450: break;
1451: case 1:
1452: return $this->getParent();
1453: break;
1454: case 2:
1455: return $this->getLink();
1456: break;
1457: case 3:
1458: return $this->getVisible();
1459: break;
1460: case 4:
1461: return $this->getPosition();
1462: break;
1463: case 5:
1464: return $this->getCreatedAt();
1465: break;
1466: case 6:
1467: return $this->getUpdatedAt();
1468: break;
1469: case 7:
1470: return $this->getVersion();
1471: break;
1472: case 8:
1473: return $this->getVersionCreatedAt();
1474: break;
1475: case 9:
1476: return $this->getVersionCreatedBy();
1477: break;
1478: default:
1479: return null;
1480: break;
1481: }
1482: }
1483:
1484: 1485: 1486: 1487: 1488: 1489: 1490: 1491: 1492: 1493: 1494: 1495: 1496: 1497: 1498:
1499: public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
1500: {
1501: if (isset($alreadyDumpedObjects['Category'][$this->getPrimaryKey()])) {
1502: return '*RECURSION*';
1503: }
1504: $alreadyDumpedObjects['Category'][$this->getPrimaryKey()] = true;
1505: $keys = CategoryPeer::getFieldNames($keyType);
1506: $result = array(
1507: $keys[0] => $this->getId(),
1508: $keys[1] => $this->getParent(),
1509: $keys[2] => $this->getLink(),
1510: $keys[3] => $this->getVisible(),
1511: $keys[4] => $this->getPosition(),
1512: $keys[5] => $this->getCreatedAt(),
1513: $keys[6] => $this->getUpdatedAt(),
1514: $keys[7] => $this->getVersion(),
1515: $keys[8] => $this->getVersionCreatedAt(),
1516: $keys[9] => $this->getVersionCreatedBy(),
1517: );
1518: if ($includeForeignObjects) {
1519: if (null !== $this->collProductCategorys) {
1520: $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1521: }
1522: if (null !== $this->collFeatureCategorys) {
1523: $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1524: }
1525: if (null !== $this->collAttributeCategorys) {
1526: $result['AttributeCategorys'] = $this->collAttributeCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1527: }
1528: if (null !== $this->collContentAssocs) {
1529: $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1530: }
1531: if (null !== $this->collImages) {
1532: $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1533: }
1534: if (null !== $this->collDocuments) {
1535: $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1536: }
1537: if (null !== $this->collRewritings) {
1538: $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1539: }
1540: if (null !== $this->collCategoryI18ns) {
1541: $result['CategoryI18ns'] = $this->collCategoryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1542: }
1543: if (null !== $this->collCategoryVersions) {
1544: $result['CategoryVersions'] = $this->collCategoryVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1545: }
1546: }
1547:
1548: return $result;
1549: }
1550:
1551: 1552: 1553: 1554: 1555: 1556: 1557: 1558: 1559: 1560: 1561:
1562: public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
1563: {
1564: $pos = CategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1565:
1566: $this->setByPosition($pos, $value);
1567: }
1568:
1569: 1570: 1571: 1572: 1573: 1574: 1575: 1576:
1577: public function setByPosition($pos, $value)
1578: {
1579: switch ($pos) {
1580: case 0:
1581: $this->setId($value);
1582: break;
1583: case 1:
1584: $this->setParent($value);
1585: break;
1586: case 2:
1587: $this->setLink($value);
1588: break;
1589: case 3:
1590: $this->setVisible($value);
1591: break;
1592: case 4:
1593: $this->setPosition($value);
1594: break;
1595: case 5:
1596: $this->setCreatedAt($value);
1597: break;
1598: case 6:
1599: $this->setUpdatedAt($value);
1600: break;
1601: case 7:
1602: $this->setVersion($value);
1603: break;
1604: case 8:
1605: $this->setVersionCreatedAt($value);
1606: break;
1607: case 9:
1608: $this->setVersionCreatedBy($value);
1609: break;
1610: }
1611: }
1612:
1613: 1614: 1615: 1616: 1617: 1618: 1619: 1620: 1621: 1622: 1623: 1624: 1625: 1626: 1627: 1628: 1629:
1630: public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
1631: {
1632: $keys = CategoryPeer::getFieldNames($keyType);
1633:
1634: if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
1635: if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]);
1636: if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]);
1637: if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]);
1638: if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
1639: if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
1640: if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
1641: if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]);
1642: if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]);
1643: if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]);
1644: }
1645:
1646: 1647: 1648: 1649: 1650:
1651: public function buildCriteria()
1652: {
1653: $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
1654:
1655: if ($this->isColumnModified(CategoryPeer::ID)) $criteria->add(CategoryPeer::ID, $this->id);
1656: if ($this->isColumnModified(CategoryPeer::PARENT)) $criteria->add(CategoryPeer::PARENT, $this->parent);
1657: if ($this->isColumnModified(CategoryPeer::LINK)) $criteria->add(CategoryPeer::LINK, $this->link);
1658: if ($this->isColumnModified(CategoryPeer::VISIBLE)) $criteria->add(CategoryPeer::VISIBLE, $this->visible);
1659: if ($this->isColumnModified(CategoryPeer::POSITION)) $criteria->add(CategoryPeer::POSITION, $this->position);
1660: if ($this->isColumnModified(CategoryPeer::CREATED_AT)) $criteria->add(CategoryPeer::CREATED_AT, $this->created_at);
1661: if ($this->isColumnModified(CategoryPeer::UPDATED_AT)) $criteria->add(CategoryPeer::UPDATED_AT, $this->updated_at);
1662: if ($this->isColumnModified(CategoryPeer::VERSION)) $criteria->add(CategoryPeer::VERSION, $this->version);
1663: if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_AT)) $criteria->add(CategoryPeer::VERSION_CREATED_AT, $this->version_created_at);
1664: if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_BY)) $criteria->add(CategoryPeer::VERSION_CREATED_BY, $this->version_created_by);
1665:
1666: return $criteria;
1667: }
1668:
1669: 1670: 1671: 1672: 1673: 1674: 1675: 1676:
1677: public function buildPkeyCriteria()
1678: {
1679: $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
1680: $criteria->add(CategoryPeer::ID, $this->id);
1681:
1682: return $criteria;
1683: }
1684:
1685: 1686: 1687: 1688:
1689: public function getPrimaryKey()
1690: {
1691: return $this->getId();
1692: }
1693:
1694: 1695: 1696: 1697: 1698: 1699:
1700: public function setPrimaryKey($key)
1701: {
1702: $this->setId($key);
1703: }
1704:
1705: 1706: 1707: 1708:
1709: public function isPrimaryKeyNull()
1710: {
1711:
1712: return null === $this->getId();
1713: }
1714:
1715: 1716: 1717: 1718: 1719: 1720: 1721: 1722: 1723: 1724: 1725:
1726: public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1727: {
1728: $copyObj->setParent($this->getParent());
1729: $copyObj->setLink($this->getLink());
1730: $copyObj->setVisible($this->getVisible());
1731: $copyObj->setPosition($this->getPosition());
1732: $copyObj->setCreatedAt($this->getCreatedAt());
1733: $copyObj->setUpdatedAt($this->getUpdatedAt());
1734: $copyObj->setVersion($this->getVersion());
1735: $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
1736: $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
1737:
1738: if ($deepCopy && !$this->startCopy) {
1739:
1740:
1741: $copyObj->setNew(false);
1742:
1743: $this->startCopy = true;
1744:
1745: foreach ($this->getProductCategorys() as $relObj) {
1746: if ($relObj !== $this) {
1747: $copyObj->addProductCategory($relObj->copy($deepCopy));
1748: }
1749: }
1750:
1751: foreach ($this->getFeatureCategorys() as $relObj) {
1752: if ($relObj !== $this) {
1753: $copyObj->addFeatureCategory($relObj->copy($deepCopy));
1754: }
1755: }
1756:
1757: foreach ($this->getAttributeCategorys() as $relObj) {
1758: if ($relObj !== $this) {
1759: $copyObj->addAttributeCategory($relObj->copy($deepCopy));
1760: }
1761: }
1762:
1763: foreach ($this->getContentAssocs() as $relObj) {
1764: if ($relObj !== $this) {
1765: $copyObj->addContentAssoc($relObj->copy($deepCopy));
1766: }
1767: }
1768:
1769: foreach ($this->getImages() as $relObj) {
1770: if ($relObj !== $this) {
1771: $copyObj->addImage($relObj->copy($deepCopy));
1772: }
1773: }
1774:
1775: foreach ($this->getDocuments() as $relObj) {
1776: if ($relObj !== $this) {
1777: $copyObj->addDocument($relObj->copy($deepCopy));
1778: }
1779: }
1780:
1781: foreach ($this->getRewritings() as $relObj) {
1782: if ($relObj !== $this) {
1783: $copyObj->addRewriting($relObj->copy($deepCopy));
1784: }
1785: }
1786:
1787: foreach ($this->getCategoryI18ns() as $relObj) {
1788: if ($relObj !== $this) {
1789: $copyObj->addCategoryI18n($relObj->copy($deepCopy));
1790: }
1791: }
1792:
1793: foreach ($this->getCategoryVersions() as $relObj) {
1794: if ($relObj !== $this) {
1795: $copyObj->addCategoryVersion($relObj->copy($deepCopy));
1796: }
1797: }
1798:
1799:
1800: $this->startCopy = false;
1801: }
1802:
1803: if ($makeNew) {
1804: $copyObj->setNew(true);
1805: $copyObj->setId(NULL);
1806: }
1807: }
1808:
1809: 1810: 1811: 1812: 1813: 1814: 1815: 1816: 1817: 1818: 1819: 1820:
1821: public function copy($deepCopy = false)
1822: {
1823:
1824: $clazz = get_class($this);
1825: $copyObj = new $clazz();
1826: $this->copyInto($copyObj, $deepCopy);
1827:
1828: return $copyObj;
1829: }
1830:
1831: 1832: 1833: 1834: 1835: 1836: 1837: 1838: 1839:
1840: public function getPeer()
1841: {
1842: if (self::$peer === null) {
1843: self::$peer = new CategoryPeer();
1844: }
1845:
1846: return self::$peer;
1847: }
1848:
1849:
1850: 1851: 1852: 1853: 1854: 1855: 1856: 1857:
1858: public function initRelation($relationName)
1859: {
1860: if ('ProductCategory' == $relationName) {
1861: $this->initProductCategorys();
1862: }
1863: if ('FeatureCategory' == $relationName) {
1864: $this->initFeatureCategorys();
1865: }
1866: if ('AttributeCategory' == $relationName) {
1867: $this->initAttributeCategorys();
1868: }
1869: if ('ContentAssoc' == $relationName) {
1870: $this->initContentAssocs();
1871: }
1872: if ('Image' == $relationName) {
1873: $this->initImages();
1874: }
1875: if ('Document' == $relationName) {
1876: $this->initDocuments();
1877: }
1878: if ('Rewriting' == $relationName) {
1879: $this->initRewritings();
1880: }
1881: if ('CategoryI18n' == $relationName) {
1882: $this->initCategoryI18ns();
1883: }
1884: if ('CategoryVersion' == $relationName) {
1885: $this->initCategoryVersions();
1886: }
1887: }
1888:
1889: 1890: 1891: 1892: 1893: 1894: 1895: 1896: 1897:
1898: public function clearProductCategorys()
1899: {
1900: $this->collProductCategorys = null;
1901: $this->collProductCategorysPartial = null;
1902:
1903: return $this;
1904: }
1905:
1906: 1907: 1908: 1909: 1910:
1911: public function resetPartialProductCategorys($v = true)
1912: {
1913: $this->collProductCategorysPartial = $v;
1914: }
1915:
1916: 1917: 1918: 1919: 1920: 1921: 1922: 1923: 1924: 1925: 1926: 1927:
1928: public function initProductCategorys($overrideExisting = true)
1929: {
1930: if (null !== $this->collProductCategorys && !$overrideExisting) {
1931: return;
1932: }
1933: $this->collProductCategorys = new PropelObjectCollection();
1934: $this->collProductCategorys->setModel('ProductCategory');
1935: }
1936:
1937: 1938: 1939: 1940: 1941: 1942: 1943: 1944: 1945: 1946: 1947: 1948: 1949: 1950:
1951: public function getProductCategorys($criteria = null, PropelPDO $con = null)
1952: {
1953: $partial = $this->collProductCategorysPartial && !$this->isNew();
1954: if (null === $this->collProductCategorys || null !== $criteria || $partial) {
1955: if ($this->isNew() && null === $this->collProductCategorys) {
1956:
1957: $this->initProductCategorys();
1958: } else {
1959: $collProductCategorys = ProductCategoryQuery::create(null, $criteria)
1960: ->filterByCategory($this)
1961: ->find($con);
1962: if (null !== $criteria) {
1963: if (false !== $this->collProductCategorysPartial && count($collProductCategorys)) {
1964: $this->initProductCategorys(false);
1965:
1966: foreach($collProductCategorys as $obj) {
1967: if (false == $this->collProductCategorys->contains($obj)) {
1968: $this->collProductCategorys->append($obj);
1969: }
1970: }
1971:
1972: $this->collProductCategorysPartial = true;
1973: }
1974:
1975: $collProductCategorys->getInternalIterator()->rewind();
1976: return $collProductCategorys;
1977: }
1978:
1979: if($partial && $this->collProductCategorys) {
1980: foreach($this->collProductCategorys as $obj) {
1981: if($obj->isNew()) {
1982: $collProductCategorys[] = $obj;
1983: }
1984: }
1985: }
1986:
1987: $this->collProductCategorys = $collProductCategorys;
1988: $this->collProductCategorysPartial = false;
1989: }
1990: }
1991:
1992: return $this->collProductCategorys;
1993: }
1994:
1995: 1996: 1997: 1998: 1999: 2000: 2001: 2002: 2003: 2004:
2005: public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null)
2006: {
2007: $productCategorysToDelete = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys);
2008:
2009: $this->productCategorysScheduledForDeletion = unserialize(serialize($productCategorysToDelete));
2010:
2011: foreach ($productCategorysToDelete as $productCategoryRemoved) {
2012: $productCategoryRemoved->setCategory(null);
2013: }
2014:
2015: $this->collProductCategorys = null;
2016: foreach ($productCategorys as $productCategory) {
2017: $this->addProductCategory($productCategory);
2018: }
2019:
2020: $this->collProductCategorys = $productCategorys;
2021: $this->collProductCategorysPartial = false;
2022:
2023: return $this;
2024: }
2025:
2026: 2027: 2028: 2029: 2030: 2031: 2032: 2033: 2034:
2035: public function countProductCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2036: {
2037: $partial = $this->collProductCategorysPartial && !$this->isNew();
2038: if (null === $this->collProductCategorys || null !== $criteria || $partial) {
2039: if ($this->isNew() && null === $this->collProductCategorys) {
2040: return 0;
2041: }
2042:
2043: if($partial && !$criteria) {
2044: return count($this->getProductCategorys());
2045: }
2046: $query = ProductCategoryQuery::create(null, $criteria);
2047: if ($distinct) {
2048: $query->distinct();
2049: }
2050:
2051: return $query
2052: ->filterByCategory($this)
2053: ->count($con);
2054: }
2055:
2056: return count($this->collProductCategorys);
2057: }
2058:
2059: 2060: 2061: 2062: 2063: 2064: 2065:
2066: public function addProductCategory(ProductCategory $l)
2067: {
2068: if ($this->collProductCategorys === null) {
2069: $this->initProductCategorys();
2070: $this->collProductCategorysPartial = true;
2071: }
2072: if (!in_array($l, $this->collProductCategorys->getArrayCopy(), true)) {
2073: $this->doAddProductCategory($l);
2074: }
2075:
2076: return $this;
2077: }
2078:
2079: 2080: 2081:
2082: protected function doAddProductCategory($productCategory)
2083: {
2084: $this->collProductCategorys[]= $productCategory;
2085: $productCategory->setCategory($this);
2086: }
2087:
2088: 2089: 2090: 2091:
2092: public function removeProductCategory($productCategory)
2093: {
2094: if ($this->getProductCategorys()->contains($productCategory)) {
2095: $this->collProductCategorys->remove($this->collProductCategorys->search($productCategory));
2096: if (null === $this->productCategorysScheduledForDeletion) {
2097: $this->productCategorysScheduledForDeletion = clone $this->collProductCategorys;
2098: $this->productCategorysScheduledForDeletion->clear();
2099: }
2100: $this->productCategorysScheduledForDeletion[]= clone $productCategory;
2101: $productCategory->setCategory(null);
2102: }
2103:
2104: return $this;
2105: }
2106:
2107:
2108: 2109: 2110: 2111: 2112: 2113: 2114: 2115: 2116: 2117: 2118: 2119: 2120: 2121: 2122: 2123:
2124: public function getProductCategorysJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2125: {
2126: $query = ProductCategoryQuery::create(null, $criteria);
2127: $query->joinWith('Product', $join_behavior);
2128:
2129: return $this->getProductCategorys($query, $con);
2130: }
2131:
2132: 2133: 2134: 2135: 2136: 2137: 2138: 2139: 2140:
2141: public function clearFeatureCategorys()
2142: {
2143: $this->collFeatureCategorys = null;
2144: $this->collFeatureCategorysPartial = null;
2145:
2146: return $this;
2147: }
2148:
2149: 2150: 2151: 2152: 2153:
2154: public function resetPartialFeatureCategorys($v = true)
2155: {
2156: $this->collFeatureCategorysPartial = $v;
2157: }
2158:
2159: 2160: 2161: 2162: 2163: 2164: 2165: 2166: 2167: 2168: 2169: 2170:
2171: public function initFeatureCategorys($overrideExisting = true)
2172: {
2173: if (null !== $this->collFeatureCategorys && !$overrideExisting) {
2174: return;
2175: }
2176: $this->collFeatureCategorys = new PropelObjectCollection();
2177: $this->collFeatureCategorys->setModel('FeatureCategory');
2178: }
2179:
2180: 2181: 2182: 2183: 2184: 2185: 2186: 2187: 2188: 2189: 2190: 2191: 2192: 2193:
2194: public function getFeatureCategorys($criteria = null, PropelPDO $con = null)
2195: {
2196: $partial = $this->collFeatureCategorysPartial && !$this->isNew();
2197: if (null === $this->collFeatureCategorys || null !== $criteria || $partial) {
2198: if ($this->isNew() && null === $this->collFeatureCategorys) {
2199:
2200: $this->initFeatureCategorys();
2201: } else {
2202: $collFeatureCategorys = FeatureCategoryQuery::create(null, $criteria)
2203: ->filterByCategory($this)
2204: ->find($con);
2205: if (null !== $criteria) {
2206: if (false !== $this->collFeatureCategorysPartial && count($collFeatureCategorys)) {
2207: $this->initFeatureCategorys(false);
2208:
2209: foreach($collFeatureCategorys as $obj) {
2210: if (false == $this->collFeatureCategorys->contains($obj)) {
2211: $this->collFeatureCategorys->append($obj);
2212: }
2213: }
2214:
2215: $this->collFeatureCategorysPartial = true;
2216: }
2217:
2218: $collFeatureCategorys->getInternalIterator()->rewind();
2219: return $collFeatureCategorys;
2220: }
2221:
2222: if($partial && $this->collFeatureCategorys) {
2223: foreach($this->collFeatureCategorys as $obj) {
2224: if($obj->isNew()) {
2225: $collFeatureCategorys[] = $obj;
2226: }
2227: }
2228: }
2229:
2230: $this->collFeatureCategorys = $collFeatureCategorys;
2231: $this->collFeatureCategorysPartial = false;
2232: }
2233: }
2234:
2235: return $this->collFeatureCategorys;
2236: }
2237:
2238: 2239: 2240: 2241: 2242: 2243: 2244: 2245: 2246: 2247:
2248: public function setFeatureCategorys(PropelCollection $featureCategorys, PropelPDO $con = null)
2249: {
2250: $featureCategorysToDelete = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys);
2251:
2252: $this->featureCategorysScheduledForDeletion = unserialize(serialize($featureCategorysToDelete));
2253:
2254: foreach ($featureCategorysToDelete as $featureCategoryRemoved) {
2255: $featureCategoryRemoved->setCategory(null);
2256: }
2257:
2258: $this->collFeatureCategorys = null;
2259: foreach ($featureCategorys as $featureCategory) {
2260: $this->addFeatureCategory($featureCategory);
2261: }
2262:
2263: $this->collFeatureCategorys = $featureCategorys;
2264: $this->collFeatureCategorysPartial = false;
2265:
2266: return $this;
2267: }
2268:
2269: 2270: 2271: 2272: 2273: 2274: 2275: 2276: 2277:
2278: public function countFeatureCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2279: {
2280: $partial = $this->collFeatureCategorysPartial && !$this->isNew();
2281: if (null === $this->collFeatureCategorys || null !== $criteria || $partial) {
2282: if ($this->isNew() && null === $this->collFeatureCategorys) {
2283: return 0;
2284: }
2285:
2286: if($partial && !$criteria) {
2287: return count($this->getFeatureCategorys());
2288: }
2289: $query = FeatureCategoryQuery::create(null, $criteria);
2290: if ($distinct) {
2291: $query->distinct();
2292: }
2293:
2294: return $query
2295: ->filterByCategory($this)
2296: ->count($con);
2297: }
2298:
2299: return count($this->collFeatureCategorys);
2300: }
2301:
2302: 2303: 2304: 2305: 2306: 2307: 2308:
2309: public function addFeatureCategory(FeatureCategory $l)
2310: {
2311: if ($this->collFeatureCategorys === null) {
2312: $this->initFeatureCategorys();
2313: $this->collFeatureCategorysPartial = true;
2314: }
2315: if (!in_array($l, $this->collFeatureCategorys->getArrayCopy(), true)) {
2316: $this->doAddFeatureCategory($l);
2317: }
2318:
2319: return $this;
2320: }
2321:
2322: 2323: 2324:
2325: protected function doAddFeatureCategory($featureCategory)
2326: {
2327: $this->collFeatureCategorys[]= $featureCategory;
2328: $featureCategory->setCategory($this);
2329: }
2330:
2331: 2332: 2333: 2334:
2335: public function removeFeatureCategory($featureCategory)
2336: {
2337: if ($this->getFeatureCategorys()->contains($featureCategory)) {
2338: $this->collFeatureCategorys->remove($this->collFeatureCategorys->search($featureCategory));
2339: if (null === $this->featureCategorysScheduledForDeletion) {
2340: $this->featureCategorysScheduledForDeletion = clone $this->collFeatureCategorys;
2341: $this->featureCategorysScheduledForDeletion->clear();
2342: }
2343: $this->featureCategorysScheduledForDeletion[]= clone $featureCategory;
2344: $featureCategory->setCategory(null);
2345: }
2346:
2347: return $this;
2348: }
2349:
2350:
2351: 2352: 2353: 2354: 2355: 2356: 2357: 2358: 2359: 2360: 2361: 2362: 2363: 2364: 2365: 2366:
2367: public function getFeatureCategorysJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2368: {
2369: $query = FeatureCategoryQuery::create(null, $criteria);
2370: $query->joinWith('Feature', $join_behavior);
2371:
2372: return $this->getFeatureCategorys($query, $con);
2373: }
2374:
2375: 2376: 2377: 2378: 2379: 2380: 2381: 2382: 2383:
2384: public function clearAttributeCategorys()
2385: {
2386: $this->collAttributeCategorys = null;
2387: $this->collAttributeCategorysPartial = null;
2388:
2389: return $this;
2390: }
2391:
2392: 2393: 2394: 2395: 2396:
2397: public function resetPartialAttributeCategorys($v = true)
2398: {
2399: $this->collAttributeCategorysPartial = $v;
2400: }
2401:
2402: 2403: 2404: 2405: 2406: 2407: 2408: 2409: 2410: 2411: 2412: 2413:
2414: public function initAttributeCategorys($overrideExisting = true)
2415: {
2416: if (null !== $this->collAttributeCategorys && !$overrideExisting) {
2417: return;
2418: }
2419: $this->collAttributeCategorys = new PropelObjectCollection();
2420: $this->collAttributeCategorys->setModel('AttributeCategory');
2421: }
2422:
2423: 2424: 2425: 2426: 2427: 2428: 2429: 2430: 2431: 2432: 2433: 2434: 2435: 2436:
2437: public function getAttributeCategorys($criteria = null, PropelPDO $con = null)
2438: {
2439: $partial = $this->collAttributeCategorysPartial && !$this->isNew();
2440: if (null === $this->collAttributeCategorys || null !== $criteria || $partial) {
2441: if ($this->isNew() && null === $this->collAttributeCategorys) {
2442:
2443: $this->initAttributeCategorys();
2444: } else {
2445: $collAttributeCategorys = AttributeCategoryQuery::create(null, $criteria)
2446: ->filterByCategory($this)
2447: ->find($con);
2448: if (null !== $criteria) {
2449: if (false !== $this->collAttributeCategorysPartial && count($collAttributeCategorys)) {
2450: $this->initAttributeCategorys(false);
2451:
2452: foreach($collAttributeCategorys as $obj) {
2453: if (false == $this->collAttributeCategorys->contains($obj)) {
2454: $this->collAttributeCategorys->append($obj);
2455: }
2456: }
2457:
2458: $this->collAttributeCategorysPartial = true;
2459: }
2460:
2461: $collAttributeCategorys->getInternalIterator()->rewind();
2462: return $collAttributeCategorys;
2463: }
2464:
2465: if($partial && $this->collAttributeCategorys) {
2466: foreach($this->collAttributeCategorys as $obj) {
2467: if($obj->isNew()) {
2468: $collAttributeCategorys[] = $obj;
2469: }
2470: }
2471: }
2472:
2473: $this->collAttributeCategorys = $collAttributeCategorys;
2474: $this->collAttributeCategorysPartial = false;
2475: }
2476: }
2477:
2478: return $this->collAttributeCategorys;
2479: }
2480:
2481: 2482: 2483: 2484: 2485: 2486: 2487: 2488: 2489: 2490:
2491: public function setAttributeCategorys(PropelCollection $attributeCategorys, PropelPDO $con = null)
2492: {
2493: $attributeCategorysToDelete = $this->getAttributeCategorys(new Criteria(), $con)->diff($attributeCategorys);
2494:
2495: $this->attributeCategorysScheduledForDeletion = unserialize(serialize($attributeCategorysToDelete));
2496:
2497: foreach ($attributeCategorysToDelete as $attributeCategoryRemoved) {
2498: $attributeCategoryRemoved->setCategory(null);
2499: }
2500:
2501: $this->collAttributeCategorys = null;
2502: foreach ($attributeCategorys as $attributeCategory) {
2503: $this->addAttributeCategory($attributeCategory);
2504: }
2505:
2506: $this->collAttributeCategorys = $attributeCategorys;
2507: $this->collAttributeCategorysPartial = false;
2508:
2509: return $this;
2510: }
2511:
2512: 2513: 2514: 2515: 2516: 2517: 2518: 2519: 2520:
2521: public function countAttributeCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2522: {
2523: $partial = $this->collAttributeCategorysPartial && !$this->isNew();
2524: if (null === $this->collAttributeCategorys || null !== $criteria || $partial) {
2525: if ($this->isNew() && null === $this->collAttributeCategorys) {
2526: return 0;
2527: }
2528:
2529: if($partial && !$criteria) {
2530: return count($this->getAttributeCategorys());
2531: }
2532: $query = AttributeCategoryQuery::create(null, $criteria);
2533: if ($distinct) {
2534: $query->distinct();
2535: }
2536:
2537: return $query
2538: ->filterByCategory($this)
2539: ->count($con);
2540: }
2541:
2542: return count($this->collAttributeCategorys);
2543: }
2544:
2545: 2546: 2547: 2548: 2549: 2550: 2551:
2552: public function addAttributeCategory(AttributeCategory $l)
2553: {
2554: if ($this->collAttributeCategorys === null) {
2555: $this->initAttributeCategorys();
2556: $this->collAttributeCategorysPartial = true;
2557: }
2558: if (!in_array($l, $this->collAttributeCategorys->getArrayCopy(), true)) {
2559: $this->doAddAttributeCategory($l);
2560: }
2561:
2562: return $this;
2563: }
2564:
2565: 2566: 2567:
2568: protected function doAddAttributeCategory($attributeCategory)
2569: {
2570: $this->collAttributeCategorys[]= $attributeCategory;
2571: $attributeCategory->setCategory($this);
2572: }
2573:
2574: 2575: 2576: 2577:
2578: public function removeAttributeCategory($attributeCategory)
2579: {
2580: if ($this->getAttributeCategorys()->contains($attributeCategory)) {
2581: $this->collAttributeCategorys->remove($this->collAttributeCategorys->search($attributeCategory));
2582: if (null === $this->attributeCategorysScheduledForDeletion) {
2583: $this->attributeCategorysScheduledForDeletion = clone $this->collAttributeCategorys;
2584: $this->attributeCategorysScheduledForDeletion->clear();
2585: }
2586: $this->attributeCategorysScheduledForDeletion[]= clone $attributeCategory;
2587: $attributeCategory->setCategory(null);
2588: }
2589:
2590: return $this;
2591: }
2592:
2593:
2594: 2595: 2596: 2597: 2598: 2599: 2600: 2601: 2602: 2603: 2604: 2605: 2606: 2607: 2608: 2609:
2610: public function getAttributeCategorysJoinAttribute($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2611: {
2612: $query = AttributeCategoryQuery::create(null, $criteria);
2613: $query->joinWith('Attribute', $join_behavior);
2614:
2615: return $this->getAttributeCategorys($query, $con);
2616: }
2617:
2618: 2619: 2620: 2621: 2622: 2623: 2624: 2625: 2626:
2627: public function clearContentAssocs()
2628: {
2629: $this->collContentAssocs = null;
2630: $this->collContentAssocsPartial = null;
2631:
2632: return $this;
2633: }
2634:
2635: 2636: 2637: 2638: 2639:
2640: public function resetPartialContentAssocs($v = true)
2641: {
2642: $this->collContentAssocsPartial = $v;
2643: }
2644:
2645: 2646: 2647: 2648: 2649: 2650: 2651: 2652: 2653: 2654: 2655: 2656:
2657: public function initContentAssocs($overrideExisting = true)
2658: {
2659: if (null !== $this->collContentAssocs && !$overrideExisting) {
2660: return;
2661: }
2662: $this->collContentAssocs = new PropelObjectCollection();
2663: $this->collContentAssocs->setModel('ContentAssoc');
2664: }
2665:
2666: 2667: 2668: 2669: 2670: 2671: 2672: 2673: 2674: 2675: 2676: 2677: 2678: 2679:
2680: public function getContentAssocs($criteria = null, PropelPDO $con = null)
2681: {
2682: $partial = $this->collContentAssocsPartial && !$this->isNew();
2683: if (null === $this->collContentAssocs || null !== $criteria || $partial) {
2684: if ($this->isNew() && null === $this->collContentAssocs) {
2685:
2686: $this->initContentAssocs();
2687: } else {
2688: $collContentAssocs = ContentAssocQuery::create(null, $criteria)
2689: ->filterByCategory($this)
2690: ->find($con);
2691: if (null !== $criteria) {
2692: if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) {
2693: $this->initContentAssocs(false);
2694:
2695: foreach($collContentAssocs as $obj) {
2696: if (false == $this->collContentAssocs->contains($obj)) {
2697: $this->collContentAssocs->append($obj);
2698: }
2699: }
2700:
2701: $this->collContentAssocsPartial = true;
2702: }
2703:
2704: $collContentAssocs->getInternalIterator()->rewind();
2705: return $collContentAssocs;
2706: }
2707:
2708: if($partial && $this->collContentAssocs) {
2709: foreach($this->collContentAssocs as $obj) {
2710: if($obj->isNew()) {
2711: $collContentAssocs[] = $obj;
2712: }
2713: }
2714: }
2715:
2716: $this->collContentAssocs = $collContentAssocs;
2717: $this->collContentAssocsPartial = false;
2718: }
2719: }
2720:
2721: return $this->collContentAssocs;
2722: }
2723:
2724: 2725: 2726: 2727: 2728: 2729: 2730: 2731: 2732: 2733:
2734: public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null)
2735: {
2736: $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs);
2737:
2738: $this->contentAssocsScheduledForDeletion = unserialize(serialize($contentAssocsToDelete));
2739:
2740: foreach ($contentAssocsToDelete as $contentAssocRemoved) {
2741: $contentAssocRemoved->setCategory(null);
2742: }
2743:
2744: $this->collContentAssocs = null;
2745: foreach ($contentAssocs as $contentAssoc) {
2746: $this->addContentAssoc($contentAssoc);
2747: }
2748:
2749: $this->collContentAssocs = $contentAssocs;
2750: $this->collContentAssocsPartial = false;
2751:
2752: return $this;
2753: }
2754:
2755: 2756: 2757: 2758: 2759: 2760: 2761: 2762: 2763:
2764: public function countContentAssocs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2765: {
2766: $partial = $this->collContentAssocsPartial && !$this->isNew();
2767: if (null === $this->collContentAssocs || null !== $criteria || $partial) {
2768: if ($this->isNew() && null === $this->collContentAssocs) {
2769: return 0;
2770: }
2771:
2772: if($partial && !$criteria) {
2773: return count($this->getContentAssocs());
2774: }
2775: $query = ContentAssocQuery::create(null, $criteria);
2776: if ($distinct) {
2777: $query->distinct();
2778: }
2779:
2780: return $query
2781: ->filterByCategory($this)
2782: ->count($con);
2783: }
2784:
2785: return count($this->collContentAssocs);
2786: }
2787:
2788: 2789: 2790: 2791: 2792: 2793: 2794:
2795: public function addContentAssoc(ContentAssoc $l)
2796: {
2797: if ($this->collContentAssocs === null) {
2798: $this->initContentAssocs();
2799: $this->collContentAssocsPartial = true;
2800: }
2801: if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) {
2802: $this->doAddContentAssoc($l);
2803: }
2804:
2805: return $this;
2806: }
2807:
2808: 2809: 2810:
2811: protected function doAddContentAssoc($contentAssoc)
2812: {
2813: $this->collContentAssocs[]= $contentAssoc;
2814: $contentAssoc->setCategory($this);
2815: }
2816:
2817: 2818: 2819: 2820:
2821: public function removeContentAssoc($contentAssoc)
2822: {
2823: if ($this->getContentAssocs()->contains($contentAssoc)) {
2824: $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc));
2825: if (null === $this->contentAssocsScheduledForDeletion) {
2826: $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs;
2827: $this->contentAssocsScheduledForDeletion->clear();
2828: }
2829: $this->contentAssocsScheduledForDeletion[]= $contentAssoc;
2830: $contentAssoc->setCategory(null);
2831: }
2832:
2833: return $this;
2834: }
2835:
2836:
2837: 2838: 2839: 2840: 2841: 2842: 2843: 2844: 2845: 2846: 2847: 2848: 2849: 2850: 2851: 2852:
2853: public function getContentAssocsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2854: {
2855: $query = ContentAssocQuery::create(null, $criteria);
2856: $query->joinWith('Product', $join_behavior);
2857:
2858: return $this->getContentAssocs($query, $con);
2859: }
2860:
2861:
2862: 2863: 2864: 2865: 2866: 2867: 2868: 2869: 2870: 2871: 2872: 2873: 2874: 2875: 2876: 2877:
2878: public function getContentAssocsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2879: {
2880: $query = ContentAssocQuery::create(null, $criteria);
2881: $query->joinWith('Content', $join_behavior);
2882:
2883: return $this->getContentAssocs($query, $con);
2884: }
2885:
2886: 2887: 2888: 2889: 2890: 2891: 2892: 2893: 2894:
2895: public function clearImages()
2896: {
2897: $this->collImages = null;
2898: $this->collImagesPartial = null;
2899:
2900: return $this;
2901: }
2902:
2903: 2904: 2905: 2906: 2907:
2908: public function resetPartialImages($v = true)
2909: {
2910: $this->collImagesPartial = $v;
2911: }
2912:
2913: 2914: 2915: 2916: 2917: 2918: 2919: 2920: 2921: 2922: 2923: 2924:
2925: public function initImages($overrideExisting = true)
2926: {
2927: if (null !== $this->collImages && !$overrideExisting) {
2928: return;
2929: }
2930: $this->collImages = new PropelObjectCollection();
2931: $this->collImages->setModel('Image');
2932: }
2933:
2934: 2935: 2936: 2937: 2938: 2939: 2940: 2941: 2942: 2943: 2944: 2945: 2946: 2947:
2948: public function getImages($criteria = null, PropelPDO $con = null)
2949: {
2950: $partial = $this->collImagesPartial && !$this->isNew();
2951: if (null === $this->collImages || null !== $criteria || $partial) {
2952: if ($this->isNew() && null === $this->collImages) {
2953:
2954: $this->initImages();
2955: } else {
2956: $collImages = ImageQuery::create(null, $criteria)
2957: ->filterByCategory($this)
2958: ->find($con);
2959: if (null !== $criteria) {
2960: if (false !== $this->collImagesPartial && count($collImages)) {
2961: $this->initImages(false);
2962:
2963: foreach($collImages as $obj) {
2964: if (false == $this->collImages->contains($obj)) {
2965: $this->collImages->append($obj);
2966: }
2967: }
2968:
2969: $this->collImagesPartial = true;
2970: }
2971:
2972: $collImages->getInternalIterator()->rewind();
2973: return $collImages;
2974: }
2975:
2976: if($partial && $this->collImages) {
2977: foreach($this->collImages as $obj) {
2978: if($obj->isNew()) {
2979: $collImages[] = $obj;
2980: }
2981: }
2982: }
2983:
2984: $this->collImages = $collImages;
2985: $this->collImagesPartial = false;
2986: }
2987: }
2988:
2989: return $this->collImages;
2990: }
2991:
2992: 2993: 2994: 2995: 2996: 2997: 2998: 2999: 3000: 3001:
3002: public function setImages(PropelCollection $images, PropelPDO $con = null)
3003: {
3004: $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images);
3005:
3006: $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete));
3007:
3008: foreach ($imagesToDelete as $imageRemoved) {
3009: $imageRemoved->setCategory(null);
3010: }
3011:
3012: $this->collImages = null;
3013: foreach ($images as $image) {
3014: $this->addImage($image);
3015: }
3016:
3017: $this->collImages = $images;
3018: $this->collImagesPartial = false;
3019:
3020: return $this;
3021: }
3022:
3023: 3024: 3025: 3026: 3027: 3028: 3029: 3030: 3031:
3032: public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3033: {
3034: $partial = $this->collImagesPartial && !$this->isNew();
3035: if (null === $this->collImages || null !== $criteria || $partial) {
3036: if ($this->isNew() && null === $this->collImages) {
3037: return 0;
3038: }
3039:
3040: if($partial && !$criteria) {
3041: return count($this->getImages());
3042: }
3043: $query = ImageQuery::create(null, $criteria);
3044: if ($distinct) {
3045: $query->distinct();
3046: }
3047:
3048: return $query
3049: ->filterByCategory($this)
3050: ->count($con);
3051: }
3052:
3053: return count($this->collImages);
3054: }
3055:
3056: 3057: 3058: 3059: 3060: 3061: 3062:
3063: public function addImage(Image $l)
3064: {
3065: if ($this->collImages === null) {
3066: $this->initImages();
3067: $this->collImagesPartial = true;
3068: }
3069: if (!in_array($l, $this->collImages->getArrayCopy(), true)) {
3070: $this->doAddImage($l);
3071: }
3072:
3073: return $this;
3074: }
3075:
3076: 3077: 3078:
3079: protected function doAddImage($image)
3080: {
3081: $this->collImages[]= $image;
3082: $image->setCategory($this);
3083: }
3084:
3085: 3086: 3087: 3088:
3089: public function removeImage($image)
3090: {
3091: if ($this->getImages()->contains($image)) {
3092: $this->collImages->remove($this->collImages->search($image));
3093: if (null === $this->imagesScheduledForDeletion) {
3094: $this->imagesScheduledForDeletion = clone $this->collImages;
3095: $this->imagesScheduledForDeletion->clear();
3096: }
3097: $this->imagesScheduledForDeletion[]= $image;
3098: $image->setCategory(null);
3099: }
3100:
3101: return $this;
3102: }
3103:
3104:
3105: 3106: 3107: 3108: 3109: 3110: 3111: 3112: 3113: 3114: 3115: 3116: 3117: 3118: 3119: 3120:
3121: public function getImagesJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3122: {
3123: $query = ImageQuery::create(null, $criteria);
3124: $query->joinWith('Product', $join_behavior);
3125:
3126: return $this->getImages($query, $con);
3127: }
3128:
3129:
3130: 3131: 3132: 3133: 3134: 3135: 3136: 3137: 3138: 3139: 3140: 3141: 3142: 3143: 3144: 3145:
3146: public function getImagesJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3147: {
3148: $query = ImageQuery::create(null, $criteria);
3149: $query->joinWith('Content', $join_behavior);
3150:
3151: return $this->getImages($query, $con);
3152: }
3153:
3154:
3155: 3156: 3157: 3158: 3159: 3160: 3161: 3162: 3163: 3164: 3165: 3166: 3167: 3168: 3169: 3170:
3171: public function getImagesJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3172: {
3173: $query = ImageQuery::create(null, $criteria);
3174: $query->joinWith('Folder', $join_behavior);
3175:
3176: return $this->getImages($query, $con);
3177: }
3178:
3179: 3180: 3181: 3182: 3183: 3184: 3185: 3186: 3187:
3188: public function clearDocuments()
3189: {
3190: $this->collDocuments = null;
3191: $this->collDocumentsPartial = null;
3192:
3193: return $this;
3194: }
3195:
3196: 3197: 3198: 3199: 3200:
3201: public function resetPartialDocuments($v = true)
3202: {
3203: $this->collDocumentsPartial = $v;
3204: }
3205:
3206: 3207: 3208: 3209: 3210: 3211: 3212: 3213: 3214: 3215: 3216: 3217:
3218: public function initDocuments($overrideExisting = true)
3219: {
3220: if (null !== $this->collDocuments && !$overrideExisting) {
3221: return;
3222: }
3223: $this->collDocuments = new PropelObjectCollection();
3224: $this->collDocuments->setModel('Document');
3225: }
3226:
3227: 3228: 3229: 3230: 3231: 3232: 3233: 3234: 3235: 3236: 3237: 3238: 3239: 3240:
3241: public function getDocuments($criteria = null, PropelPDO $con = null)
3242: {
3243: $partial = $this->collDocumentsPartial && !$this->isNew();
3244: if (null === $this->collDocuments || null !== $criteria || $partial) {
3245: if ($this->isNew() && null === $this->collDocuments) {
3246:
3247: $this->initDocuments();
3248: } else {
3249: $collDocuments = DocumentQuery::create(null, $criteria)
3250: ->filterByCategory($this)
3251: ->find($con);
3252: if (null !== $criteria) {
3253: if (false !== $this->collDocumentsPartial && count($collDocuments)) {
3254: $this->initDocuments(false);
3255:
3256: foreach($collDocuments as $obj) {
3257: if (false == $this->collDocuments->contains($obj)) {
3258: $this->collDocuments->append($obj);
3259: }
3260: }
3261:
3262: $this->collDocumentsPartial = true;
3263: }
3264:
3265: $collDocuments->getInternalIterator()->rewind();
3266: return $collDocuments;
3267: }
3268:
3269: if($partial && $this->collDocuments) {
3270: foreach($this->collDocuments as $obj) {
3271: if($obj->isNew()) {
3272: $collDocuments[] = $obj;
3273: }
3274: }
3275: }
3276:
3277: $this->collDocuments = $collDocuments;
3278: $this->collDocumentsPartial = false;
3279: }
3280: }
3281:
3282: return $this->collDocuments;
3283: }
3284:
3285: 3286: 3287: 3288: 3289: 3290: 3291: 3292: 3293: 3294:
3295: public function setDocuments(PropelCollection $documents, PropelPDO $con = null)
3296: {
3297: $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents);
3298:
3299: $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete));
3300:
3301: foreach ($documentsToDelete as $documentRemoved) {
3302: $documentRemoved->setCategory(null);
3303: }
3304:
3305: $this->collDocuments = null;
3306: foreach ($documents as $document) {
3307: $this->addDocument($document);
3308: }
3309:
3310: $this->collDocuments = $documents;
3311: $this->collDocumentsPartial = false;
3312:
3313: return $this;
3314: }
3315:
3316: 3317: 3318: 3319: 3320: 3321: 3322: 3323: 3324:
3325: public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3326: {
3327: $partial = $this->collDocumentsPartial && !$this->isNew();
3328: if (null === $this->collDocuments || null !== $criteria || $partial) {
3329: if ($this->isNew() && null === $this->collDocuments) {
3330: return 0;
3331: }
3332:
3333: if($partial && !$criteria) {
3334: return count($this->getDocuments());
3335: }
3336: $query = DocumentQuery::create(null, $criteria);
3337: if ($distinct) {
3338: $query->distinct();
3339: }
3340:
3341: return $query
3342: ->filterByCategory($this)
3343: ->count($con);
3344: }
3345:
3346: return count($this->collDocuments);
3347: }
3348:
3349: 3350: 3351: 3352: 3353: 3354: 3355:
3356: public function addDocument(Document $l)
3357: {
3358: if ($this->collDocuments === null) {
3359: $this->initDocuments();
3360: $this->collDocumentsPartial = true;
3361: }
3362: if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) {
3363: $this->doAddDocument($l);
3364: }
3365:
3366: return $this;
3367: }
3368:
3369: 3370: 3371:
3372: protected function doAddDocument($document)
3373: {
3374: $this->collDocuments[]= $document;
3375: $document->setCategory($this);
3376: }
3377:
3378: 3379: 3380: 3381:
3382: public function removeDocument($document)
3383: {
3384: if ($this->getDocuments()->contains($document)) {
3385: $this->collDocuments->remove($this->collDocuments->search($document));
3386: if (null === $this->documentsScheduledForDeletion) {
3387: $this->documentsScheduledForDeletion = clone $this->collDocuments;
3388: $this->documentsScheduledForDeletion->clear();
3389: }
3390: $this->documentsScheduledForDeletion[]= $document;
3391: $document->setCategory(null);
3392: }
3393:
3394: return $this;
3395: }
3396:
3397:
3398: 3399: 3400: 3401: 3402: 3403: 3404: 3405: 3406: 3407: 3408: 3409: 3410: 3411: 3412: 3413:
3414: public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3415: {
3416: $query = DocumentQuery::create(null, $criteria);
3417: $query->joinWith('Product', $join_behavior);
3418:
3419: return $this->getDocuments($query, $con);
3420: }
3421:
3422:
3423: 3424: 3425: 3426: 3427: 3428: 3429: 3430: 3431: 3432: 3433: 3434: 3435: 3436: 3437: 3438:
3439: public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3440: {
3441: $query = DocumentQuery::create(null, $criteria);
3442: $query->joinWith('Content', $join_behavior);
3443:
3444: return $this->getDocuments($query, $con);
3445: }
3446:
3447:
3448: 3449: 3450: 3451: 3452: 3453: 3454: 3455: 3456: 3457: 3458: 3459: 3460: 3461: 3462: 3463:
3464: public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3465: {
3466: $query = DocumentQuery::create(null, $criteria);
3467: $query->joinWith('Folder', $join_behavior);
3468:
3469: return $this->getDocuments($query, $con);
3470: }
3471:
3472: 3473: 3474: 3475: 3476: 3477: 3478: 3479: 3480:
3481: public function clearRewritings()
3482: {
3483: $this->collRewritings = null;
3484: $this->collRewritingsPartial = null;
3485:
3486: return $this;
3487: }
3488:
3489: 3490: 3491: 3492: 3493:
3494: public function resetPartialRewritings($v = true)
3495: {
3496: $this->collRewritingsPartial = $v;
3497: }
3498:
3499: 3500: 3501: 3502: 3503: 3504: 3505: 3506: 3507: 3508: 3509: 3510:
3511: public function initRewritings($overrideExisting = true)
3512: {
3513: if (null !== $this->collRewritings && !$overrideExisting) {
3514: return;
3515: }
3516: $this->collRewritings = new PropelObjectCollection();
3517: $this->collRewritings->setModel('Rewriting');
3518: }
3519:
3520: 3521: 3522: 3523: 3524: 3525: 3526: 3527: 3528: 3529: 3530: 3531: 3532: 3533:
3534: public function getRewritings($criteria = null, PropelPDO $con = null)
3535: {
3536: $partial = $this->collRewritingsPartial && !$this->isNew();
3537: if (null === $this->collRewritings || null !== $criteria || $partial) {
3538: if ($this->isNew() && null === $this->collRewritings) {
3539:
3540: $this->initRewritings();
3541: } else {
3542: $collRewritings = RewritingQuery::create(null, $criteria)
3543: ->filterByCategory($this)
3544: ->find($con);
3545: if (null !== $criteria) {
3546: if (false !== $this->collRewritingsPartial && count($collRewritings)) {
3547: $this->initRewritings(false);
3548:
3549: foreach($collRewritings as $obj) {
3550: if (false == $this->collRewritings->contains($obj)) {
3551: $this->collRewritings->append($obj);
3552: }
3553: }
3554:
3555: $this->collRewritingsPartial = true;
3556: }
3557:
3558: $collRewritings->getInternalIterator()->rewind();
3559: return $collRewritings;
3560: }
3561:
3562: if($partial && $this->collRewritings) {
3563: foreach($this->collRewritings as $obj) {
3564: if($obj->isNew()) {
3565: $collRewritings[] = $obj;
3566: }
3567: }
3568: }
3569:
3570: $this->collRewritings = $collRewritings;
3571: $this->collRewritingsPartial = false;
3572: }
3573: }
3574:
3575: return $this->collRewritings;
3576: }
3577:
3578: 3579: 3580: 3581: 3582: 3583: 3584: 3585: 3586: 3587:
3588: public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null)
3589: {
3590: $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings);
3591:
3592: $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete));
3593:
3594: foreach ($rewritingsToDelete as $rewritingRemoved) {
3595: $rewritingRemoved->setCategory(null);
3596: }
3597:
3598: $this->collRewritings = null;
3599: foreach ($rewritings as $rewriting) {
3600: $this->addRewriting($rewriting);
3601: }
3602:
3603: $this->collRewritings = $rewritings;
3604: $this->collRewritingsPartial = false;
3605:
3606: return $this;
3607: }
3608:
3609: 3610: 3611: 3612: 3613: 3614: 3615: 3616: 3617:
3618: public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3619: {
3620: $partial = $this->collRewritingsPartial && !$this->isNew();
3621: if (null === $this->collRewritings || null !== $criteria || $partial) {
3622: if ($this->isNew() && null === $this->collRewritings) {
3623: return 0;
3624: }
3625:
3626: if($partial && !$criteria) {
3627: return count($this->getRewritings());
3628: }
3629: $query = RewritingQuery::create(null, $criteria);
3630: if ($distinct) {
3631: $query->distinct();
3632: }
3633:
3634: return $query
3635: ->filterByCategory($this)
3636: ->count($con);
3637: }
3638:
3639: return count($this->collRewritings);
3640: }
3641:
3642: 3643: 3644: 3645: 3646: 3647: 3648:
3649: public function addRewriting(Rewriting $l)
3650: {
3651: if ($this->collRewritings === null) {
3652: $this->initRewritings();
3653: $this->collRewritingsPartial = true;
3654: }
3655: if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) {
3656: $this->doAddRewriting($l);
3657: }
3658:
3659: return $this;
3660: }
3661:
3662: 3663: 3664:
3665: protected function doAddRewriting($rewriting)
3666: {
3667: $this->collRewritings[]= $rewriting;
3668: $rewriting->setCategory($this);
3669: }
3670:
3671: 3672: 3673: 3674:
3675: public function removeRewriting($rewriting)
3676: {
3677: if ($this->getRewritings()->contains($rewriting)) {
3678: $this->collRewritings->remove($this->collRewritings->search($rewriting));
3679: if (null === $this->rewritingsScheduledForDeletion) {
3680: $this->rewritingsScheduledForDeletion = clone $this->collRewritings;
3681: $this->rewritingsScheduledForDeletion->clear();
3682: }
3683: $this->rewritingsScheduledForDeletion[]= $rewriting;
3684: $rewriting->setCategory(null);
3685: }
3686:
3687: return $this;
3688: }
3689:
3690:
3691: 3692: 3693: 3694: 3695: 3696: 3697: 3698: 3699: 3700: 3701: 3702: 3703: 3704: 3705: 3706:
3707: public function getRewritingsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3708: {
3709: $query = RewritingQuery::create(null, $criteria);
3710: $query->joinWith('Product', $join_behavior);
3711:
3712: return $this->getRewritings($query, $con);
3713: }
3714:
3715:
3716: 3717: 3718: 3719: 3720: 3721: 3722: 3723: 3724: 3725: 3726: 3727: 3728: 3729: 3730: 3731:
3732: public function getRewritingsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3733: {
3734: $query = RewritingQuery::create(null, $criteria);
3735: $query->joinWith('Folder', $join_behavior);
3736:
3737: return $this->getRewritings($query, $con);
3738: }
3739:
3740:
3741: 3742: 3743: 3744: 3745: 3746: 3747: 3748: 3749: 3750: 3751: 3752: 3753: 3754: 3755: 3756:
3757: public function getRewritingsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3758: {
3759: $query = RewritingQuery::create(null, $criteria);
3760: $query->joinWith('Content', $join_behavior);
3761:
3762: return $this->getRewritings($query, $con);
3763: }
3764:
3765: 3766: 3767: 3768: 3769: 3770: 3771: 3772: 3773:
3774: public function clearCategoryI18ns()
3775: {
3776: $this->collCategoryI18ns = null;
3777: $this->collCategoryI18nsPartial = null;
3778:
3779: return $this;
3780: }
3781:
3782: 3783: 3784: 3785: 3786:
3787: public function resetPartialCategoryI18ns($v = true)
3788: {
3789: $this->collCategoryI18nsPartial = $v;
3790: }
3791:
3792: 3793: 3794: 3795: 3796: 3797: 3798: 3799: 3800: 3801: 3802: 3803:
3804: public function initCategoryI18ns($overrideExisting = true)
3805: {
3806: if (null !== $this->collCategoryI18ns && !$overrideExisting) {
3807: return;
3808: }
3809: $this->collCategoryI18ns = new PropelObjectCollection();
3810: $this->collCategoryI18ns->setModel('CategoryI18n');
3811: }
3812:
3813: 3814: 3815: 3816: 3817: 3818: 3819: 3820: 3821: 3822: 3823: 3824: 3825: 3826:
3827: public function getCategoryI18ns($criteria = null, PropelPDO $con = null)
3828: {
3829: $partial = $this->collCategoryI18nsPartial && !$this->isNew();
3830: if (null === $this->collCategoryI18ns || null !== $criteria || $partial) {
3831: if ($this->isNew() && null === $this->collCategoryI18ns) {
3832:
3833: $this->initCategoryI18ns();
3834: } else {
3835: $collCategoryI18ns = CategoryI18nQuery::create(null, $criteria)
3836: ->filterByCategory($this)
3837: ->find($con);
3838: if (null !== $criteria) {
3839: if (false !== $this->collCategoryI18nsPartial && count($collCategoryI18ns)) {
3840: $this->initCategoryI18ns(false);
3841:
3842: foreach($collCategoryI18ns as $obj) {
3843: if (false == $this->collCategoryI18ns->contains($obj)) {
3844: $this->collCategoryI18ns->append($obj);
3845: }
3846: }
3847:
3848: $this->collCategoryI18nsPartial = true;
3849: }
3850:
3851: $collCategoryI18ns->getInternalIterator()->rewind();
3852: return $collCategoryI18ns;
3853: }
3854:
3855: if($partial && $this->collCategoryI18ns) {
3856: foreach($this->collCategoryI18ns as $obj) {
3857: if($obj->isNew()) {
3858: $collCategoryI18ns[] = $obj;
3859: }
3860: }
3861: }
3862:
3863: $this->collCategoryI18ns = $collCategoryI18ns;
3864: $this->collCategoryI18nsPartial = false;
3865: }
3866: }
3867:
3868: return $this->collCategoryI18ns;
3869: }
3870:
3871: 3872: 3873: 3874: 3875: 3876: 3877: 3878: 3879: 3880:
3881: public function setCategoryI18ns(PropelCollection $categoryI18ns, PropelPDO $con = null)
3882: {
3883: $categoryI18nsToDelete = $this->getCategoryI18ns(new Criteria(), $con)->diff($categoryI18ns);
3884:
3885: $this->categoryI18nsScheduledForDeletion = unserialize(serialize($categoryI18nsToDelete));
3886:
3887: foreach ($categoryI18nsToDelete as $categoryI18nRemoved) {
3888: $categoryI18nRemoved->setCategory(null);
3889: }
3890:
3891: $this->collCategoryI18ns = null;
3892: foreach ($categoryI18ns as $categoryI18n) {
3893: $this->addCategoryI18n($categoryI18n);
3894: }
3895:
3896: $this->collCategoryI18ns = $categoryI18ns;
3897: $this->collCategoryI18nsPartial = false;
3898:
3899: return $this;
3900: }
3901:
3902: 3903: 3904: 3905: 3906: 3907: 3908: 3909: 3910:
3911: public function countCategoryI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3912: {
3913: $partial = $this->collCategoryI18nsPartial && !$this->isNew();
3914: if (null === $this->collCategoryI18ns || null !== $criteria || $partial) {
3915: if ($this->isNew() && null === $this->collCategoryI18ns) {
3916: return 0;
3917: }
3918:
3919: if($partial && !$criteria) {
3920: return count($this->getCategoryI18ns());
3921: }
3922: $query = CategoryI18nQuery::create(null, $criteria);
3923: if ($distinct) {
3924: $query->distinct();
3925: }
3926:
3927: return $query
3928: ->filterByCategory($this)
3929: ->count($con);
3930: }
3931:
3932: return count($this->collCategoryI18ns);
3933: }
3934:
3935: 3936: 3937: 3938: 3939: 3940: 3941:
3942: public function addCategoryI18n(CategoryI18n $l)
3943: {
3944: if ($l && $locale = $l->getLocale()) {
3945: $this->setLocale($locale);
3946: $this->currentTranslations[$locale] = $l;
3947: }
3948: if ($this->collCategoryI18ns === null) {
3949: $this->initCategoryI18ns();
3950: $this->collCategoryI18nsPartial = true;
3951: }
3952: if (!in_array($l, $this->collCategoryI18ns->getArrayCopy(), true)) {
3953: $this->doAddCategoryI18n($l);
3954: }
3955:
3956: return $this;
3957: }
3958:
3959: 3960: 3961:
3962: protected function doAddCategoryI18n($categoryI18n)
3963: {
3964: $this->collCategoryI18ns[]= $categoryI18n;
3965: $categoryI18n->setCategory($this);
3966: }
3967:
3968: 3969: 3970: 3971:
3972: public function removeCategoryI18n($categoryI18n)
3973: {
3974: if ($this->getCategoryI18ns()->contains($categoryI18n)) {
3975: $this->collCategoryI18ns->remove($this->collCategoryI18ns->search($categoryI18n));
3976: if (null === $this->categoryI18nsScheduledForDeletion) {
3977: $this->categoryI18nsScheduledForDeletion = clone $this->collCategoryI18ns;
3978: $this->categoryI18nsScheduledForDeletion->clear();
3979: }
3980: $this->categoryI18nsScheduledForDeletion[]= clone $categoryI18n;
3981: $categoryI18n->setCategory(null);
3982: }
3983:
3984: return $this;
3985: }
3986:
3987: 3988: 3989: 3990: 3991: 3992: 3993: 3994: 3995:
3996: public function clearCategoryVersions()
3997: {
3998: $this->collCategoryVersions = null;
3999: $this->collCategoryVersionsPartial = null;
4000:
4001: return $this;
4002: }
4003:
4004: 4005: 4006: 4007: 4008:
4009: public function resetPartialCategoryVersions($v = true)
4010: {
4011: $this->collCategoryVersionsPartial = $v;
4012: }
4013:
4014: 4015: 4016: 4017: 4018: 4019: 4020: 4021: 4022: 4023: 4024: 4025:
4026: public function initCategoryVersions($overrideExisting = true)
4027: {
4028: if (null !== $this->collCategoryVersions && !$overrideExisting) {
4029: return;
4030: }
4031: $this->collCategoryVersions = new PropelObjectCollection();
4032: $this->collCategoryVersions->setModel('CategoryVersion');
4033: }
4034:
4035: 4036: 4037: 4038: 4039: 4040: 4041: 4042: 4043: 4044: 4045: 4046: 4047: 4048:
4049: public function getCategoryVersions($criteria = null, PropelPDO $con = null)
4050: {
4051: $partial = $this->collCategoryVersionsPartial && !$this->isNew();
4052: if (null === $this->collCategoryVersions || null !== $criteria || $partial) {
4053: if ($this->isNew() && null === $this->collCategoryVersions) {
4054:
4055: $this->initCategoryVersions();
4056: } else {
4057: $collCategoryVersions = CategoryVersionQuery::create(null, $criteria)
4058: ->filterByCategory($this)
4059: ->find($con);
4060: if (null !== $criteria) {
4061: if (false !== $this->collCategoryVersionsPartial && count($collCategoryVersions)) {
4062: $this->initCategoryVersions(false);
4063:
4064: foreach($collCategoryVersions as $obj) {
4065: if (false == $this->collCategoryVersions->contains($obj)) {
4066: $this->collCategoryVersions->append($obj);
4067: }
4068: }
4069:
4070: $this->collCategoryVersionsPartial = true;
4071: }
4072:
4073: $collCategoryVersions->getInternalIterator()->rewind();
4074: return $collCategoryVersions;
4075: }
4076:
4077: if($partial && $this->collCategoryVersions) {
4078: foreach($this->collCategoryVersions as $obj) {
4079: if($obj->isNew()) {
4080: $collCategoryVersions[] = $obj;
4081: }
4082: }
4083: }
4084:
4085: $this->collCategoryVersions = $collCategoryVersions;
4086: $this->collCategoryVersionsPartial = false;
4087: }
4088: }
4089:
4090: return $this->collCategoryVersions;
4091: }
4092:
4093: 4094: 4095: 4096: 4097: 4098: 4099: 4100: 4101: 4102:
4103: public function setCategoryVersions(PropelCollection $categoryVersions, PropelPDO $con = null)
4104: {
4105: $categoryVersionsToDelete = $this->getCategoryVersions(new Criteria(), $con)->diff($categoryVersions);
4106:
4107: $this->categoryVersionsScheduledForDeletion = unserialize(serialize($categoryVersionsToDelete));
4108:
4109: foreach ($categoryVersionsToDelete as $categoryVersionRemoved) {
4110: $categoryVersionRemoved->setCategory(null);
4111: }
4112:
4113: $this->collCategoryVersions = null;
4114: foreach ($categoryVersions as $categoryVersion) {
4115: $this->addCategoryVersion($categoryVersion);
4116: }
4117:
4118: $this->collCategoryVersions = $categoryVersions;
4119: $this->collCategoryVersionsPartial = false;
4120:
4121: return $this;
4122: }
4123:
4124: 4125: 4126: 4127: 4128: 4129: 4130: 4131: 4132:
4133: public function countCategoryVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
4134: {
4135: $partial = $this->collCategoryVersionsPartial && !$this->isNew();
4136: if (null === $this->collCategoryVersions || null !== $criteria || $partial) {
4137: if ($this->isNew() && null === $this->collCategoryVersions) {
4138: return 0;
4139: }
4140:
4141: if($partial && !$criteria) {
4142: return count($this->getCategoryVersions());
4143: }
4144: $query = CategoryVersionQuery::create(null, $criteria);
4145: if ($distinct) {
4146: $query->distinct();
4147: }
4148:
4149: return $query
4150: ->filterByCategory($this)
4151: ->count($con);
4152: }
4153:
4154: return count($this->collCategoryVersions);
4155: }
4156:
4157: 4158: 4159: 4160: 4161: 4162: 4163:
4164: public function addCategoryVersion(CategoryVersion $l)
4165: {
4166: if ($this->collCategoryVersions === null) {
4167: $this->initCategoryVersions();
4168: $this->collCategoryVersionsPartial = true;
4169: }
4170: if (!in_array($l, $this->collCategoryVersions->getArrayCopy(), true)) {
4171: $this->doAddCategoryVersion($l);
4172: }
4173:
4174: return $this;
4175: }
4176:
4177: 4178: 4179:
4180: protected function doAddCategoryVersion($categoryVersion)
4181: {
4182: $this->collCategoryVersions[]= $categoryVersion;
4183: $categoryVersion->setCategory($this);
4184: }
4185:
4186: 4187: 4188: 4189:
4190: public function removeCategoryVersion($categoryVersion)
4191: {
4192: if ($this->getCategoryVersions()->contains($categoryVersion)) {
4193: $this->collCategoryVersions->remove($this->collCategoryVersions->search($categoryVersion));
4194: if (null === $this->categoryVersionsScheduledForDeletion) {
4195: $this->categoryVersionsScheduledForDeletion = clone $this->collCategoryVersions;
4196: $this->categoryVersionsScheduledForDeletion->clear();
4197: }
4198: $this->categoryVersionsScheduledForDeletion[]= clone $categoryVersion;
4199: $categoryVersion->setCategory(null);
4200: }
4201:
4202: return $this;
4203: }
4204:
4205: 4206: 4207:
4208: public function clear()
4209: {
4210: $this->id = null;
4211: $this->parent = null;
4212: $this->link = null;
4213: $this->visible = null;
4214: $this->position = null;
4215: $this->created_at = null;
4216: $this->updated_at = null;
4217: $this->version = null;
4218: $this->version_created_at = null;
4219: $this->version_created_by = null;
4220: $this->alreadyInSave = false;
4221: $this->alreadyInValidation = false;
4222: $this->alreadyInClearAllReferencesDeep = false;
4223: $this->clearAllReferences();
4224: $this->applyDefaultValues();
4225: $this->resetModified();
4226: $this->setNew(true);
4227: $this->setDeleted(false);
4228: }
4229:
4230: 4231: 4232: 4233: 4234: 4235: 4236: 4237: 4238:
4239: public function clearAllReferences($deep = false)
4240: {
4241: if ($deep && !$this->alreadyInClearAllReferencesDeep) {
4242: $this->alreadyInClearAllReferencesDeep = true;
4243: if ($this->collProductCategorys) {
4244: foreach ($this->collProductCategorys as $o) {
4245: $o->clearAllReferences($deep);
4246: }
4247: }
4248: if ($this->collFeatureCategorys) {
4249: foreach ($this->collFeatureCategorys as $o) {
4250: $o->clearAllReferences($deep);
4251: }
4252: }
4253: if ($this->collAttributeCategorys) {
4254: foreach ($this->collAttributeCategorys as $o) {
4255: $o->clearAllReferences($deep);
4256: }
4257: }
4258: if ($this->collContentAssocs) {
4259: foreach ($this->collContentAssocs as $o) {
4260: $o->clearAllReferences($deep);
4261: }
4262: }
4263: if ($this->collImages) {
4264: foreach ($this->collImages as $o) {
4265: $o->clearAllReferences($deep);
4266: }
4267: }
4268: if ($this->collDocuments) {
4269: foreach ($this->collDocuments as $o) {
4270: $o->clearAllReferences($deep);
4271: }
4272: }
4273: if ($this->collRewritings) {
4274: foreach ($this->collRewritings as $o) {
4275: $o->clearAllReferences($deep);
4276: }
4277: }
4278: if ($this->collCategoryI18ns) {
4279: foreach ($this->collCategoryI18ns as $o) {
4280: $o->clearAllReferences($deep);
4281: }
4282: }
4283: if ($this->collCategoryVersions) {
4284: foreach ($this->collCategoryVersions as $o) {
4285: $o->clearAllReferences($deep);
4286: }
4287: }
4288:
4289: $this->alreadyInClearAllReferencesDeep = false;
4290: }
4291:
4292:
4293: $this->currentLocale = 'en_US';
4294: $this->currentTranslations = null;
4295:
4296: if ($this->collProductCategorys instanceof PropelCollection) {
4297: $this->collProductCategorys->clearIterator();
4298: }
4299: $this->collProductCategorys = null;
4300: if ($this->collFeatureCategorys instanceof PropelCollection) {
4301: $this->collFeatureCategorys->clearIterator();
4302: }
4303: $this->collFeatureCategorys = null;
4304: if ($this->collAttributeCategorys instanceof PropelCollection) {
4305: $this->collAttributeCategorys->clearIterator();
4306: }
4307: $this->collAttributeCategorys = null;
4308: if ($this->collContentAssocs instanceof PropelCollection) {
4309: $this->collContentAssocs->clearIterator();
4310: }
4311: $this->collContentAssocs = null;
4312: if ($this->collImages instanceof PropelCollection) {
4313: $this->collImages->clearIterator();
4314: }
4315: $this->collImages = null;
4316: if ($this->collDocuments instanceof PropelCollection) {
4317: $this->collDocuments->clearIterator();
4318: }
4319: $this->collDocuments = null;
4320: if ($this->collRewritings instanceof PropelCollection) {
4321: $this->collRewritings->clearIterator();
4322: }
4323: $this->collRewritings = null;
4324: if ($this->collCategoryI18ns instanceof PropelCollection) {
4325: $this->collCategoryI18ns->clearIterator();
4326: }
4327: $this->collCategoryI18ns = null;
4328: if ($this->collCategoryVersions instanceof PropelCollection) {
4329: $this->collCategoryVersions->clearIterator();
4330: }
4331: $this->collCategoryVersions = null;
4332: }
4333:
4334: 4335: 4336: 4337: 4338:
4339: public function __toString()
4340: {
4341: return (string) $this->exportTo(CategoryPeer::DEFAULT_STRING_FORMAT);
4342: }
4343:
4344: 4345: 4346: 4347: 4348:
4349: public function isAlreadyInSave()
4350: {
4351: return $this->alreadyInSave;
4352: }
4353:
4354:
4355:
4356: 4357: 4358: 4359: 4360:
4361: public function keepUpdateDateUnchanged()
4362: {
4363: $this->modifiedColumns[] = CategoryPeer::UPDATED_AT;
4364:
4365: return $this;
4366: }
4367:
4368:
4369:
4370: 4371: 4372: 4373: 4374: 4375: 4376:
4377: public function setLocale($locale = 'en_US')
4378: {
4379: $this->currentLocale = $locale;
4380:
4381: return $this;
4382: }
4383:
4384: 4385: 4386: 4387: 4388:
4389: public function getLocale()
4390: {
4391: return $this->currentLocale;
4392: }
4393:
4394: 4395: 4396: 4397: 4398: 4399: 4400:
4401: public function getTranslation($locale = 'en_US', PropelPDO $con = null)
4402: {
4403: if (!isset($this->currentTranslations[$locale])) {
4404: if (null !== $this->collCategoryI18ns) {
4405: foreach ($this->collCategoryI18ns as $translation) {
4406: if ($translation->getLocale() == $locale) {
4407: $this->currentTranslations[$locale] = $translation;
4408:
4409: return $translation;
4410: }
4411: }
4412: }
4413: if ($this->isNew()) {
4414: $translation = new CategoryI18n();
4415: $translation->setLocale($locale);
4416: } else {
4417: $translation = CategoryI18nQuery::create()
4418: ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
4419: ->findOneOrCreate($con);
4420: $this->currentTranslations[$locale] = $translation;
4421: }
4422: $this->addCategoryI18n($translation);
4423: }
4424:
4425: return $this->currentTranslations[$locale];
4426: }
4427:
4428: 4429: 4430: 4431: 4432: 4433: 4434: 4435:
4436: public function removeTranslation($locale = 'en_US', PropelPDO $con = null)
4437: {
4438: if (!$this->isNew()) {
4439: CategoryI18nQuery::create()
4440: ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
4441: ->delete($con);
4442: }
4443: if (isset($this->currentTranslations[$locale])) {
4444: unset($this->currentTranslations[$locale]);
4445: }
4446: foreach ($this->collCategoryI18ns as $key => $translation) {
4447: if ($translation->getLocale() == $locale) {
4448: unset($this->collCategoryI18ns[$key]);
4449: break;
4450: }
4451: }
4452:
4453: return $this;
4454: }
4455:
4456: 4457: 4458: 4459: 4460: 4461:
4462: public function getCurrentTranslation(PropelPDO $con = null)
4463: {
4464: return $this->getTranslation($this->getLocale(), $con);
4465: }
4466:
4467:
4468: 4469: 4470: 4471: 4472:
4473: public function getTitle()
4474: {
4475: return $this->getCurrentTranslation()->getTitle();
4476: }
4477:
4478:
4479: 4480: 4481: 4482: 4483: 4484:
4485: public function setTitle($v)
4486: { $this->getCurrentTranslation()->setTitle($v);
4487:
4488: return $this;
4489: }
4490:
4491:
4492: 4493: 4494: 4495: 4496:
4497: public function getDescription()
4498: {
4499: return $this->getCurrentTranslation()->getDescription();
4500: }
4501:
4502:
4503: 4504: 4505: 4506: 4507: 4508:
4509: public function setDescription($v)
4510: { $this->getCurrentTranslation()->setDescription($v);
4511:
4512: return $this;
4513: }
4514:
4515:
4516: 4517: 4518: 4519: 4520:
4521: public function getChapo()
4522: {
4523: return $this->getCurrentTranslation()->getChapo();
4524: }
4525:
4526:
4527: 4528: 4529: 4530: 4531: 4532:
4533: public function setChapo($v)
4534: { $this->getCurrentTranslation()->setChapo($v);
4535:
4536: return $this;
4537: }
4538:
4539:
4540: 4541: 4542: 4543: 4544:
4545: public function getPostscriptum()
4546: {
4547: return $this->getCurrentTranslation()->getPostscriptum();
4548: }
4549:
4550:
4551: 4552: 4553: 4554: 4555: 4556:
4557: public function setPostscriptum($v)
4558: { $this->getCurrentTranslation()->setPostscriptum($v);
4559:
4560: return $this;
4561: }
4562:
4563:
4564:
4565: 4566: 4567: 4568: 4569:
4570: public function enforceVersioning()
4571: {
4572: $this->enforceVersion = true;
4573:
4574: return $this;
4575: }
4576:
4577: 4578: 4579: 4580: 4581: 4582: 4583:
4584: public function isVersioningNecessary($con = null)
4585: {
4586: if ($this->alreadyInSave) {
4587: return false;
4588: }
4589:
4590: if ($this->enforceVersion) {
4591: return true;
4592: }
4593:
4594: if (CategoryPeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) {
4595: return true;
4596: }
4597:
4598: return false;
4599: }
4600:
4601: 4602: 4603: 4604: 4605: 4606: 4607:
4608: public function addVersion($con = null)
4609: {
4610: $this->enforceVersion = false;
4611:
4612: $version = new CategoryVersion();
4613: $version->setId($this->getId());
4614: $version->setParent($this->getParent());
4615: $version->setLink($this->getLink());
4616: $version->setVisible($this->getVisible());
4617: $version->setPosition($this->getPosition());
4618: $version->setCreatedAt($this->getCreatedAt());
4619: $version->setUpdatedAt($this->getUpdatedAt());
4620: $version->setVersion($this->getVersion());
4621: $version->setVersionCreatedAt($this->getVersionCreatedAt());
4622: $version->setVersionCreatedBy($this->getVersionCreatedBy());
4623: $version->setCategory($this);
4624: $version->save($con);
4625:
4626: return $version;
4627: }
4628:
4629: 4630: 4631: 4632: 4633: 4634: 4635: 4636: 4637:
4638: public function toVersion($versionNumber, $con = null)
4639: {
4640: $version = $this->getOneVersion($versionNumber, $con);
4641: if (!$version) {
4642: throw new PropelException(sprintf('No Category object found with version %d', $version));
4643: }
4644: $this->populateFromVersion($version, $con);
4645:
4646: return $this;
4647: }
4648:
4649: 4650: 4651: 4652: 4653: 4654: 4655: 4656: 4657:
4658: public function populateFromVersion($version, $con = null, &$loadedObjects = array())
4659: {
4660:
4661: $loadedObjects['Category'][$version->getId()][$version->getVersion()] = $this;
4662: $this->setId($version->getId());
4663: $this->setParent($version->getParent());
4664: $this->setLink($version->getLink());
4665: $this->setVisible($version->getVisible());
4666: $this->setPosition($version->getPosition());
4667: $this->setCreatedAt($version->getCreatedAt());
4668: $this->setUpdatedAt($version->getUpdatedAt());
4669: $this->setVersion($version->getVersion());
4670: $this->setVersionCreatedAt($version->getVersionCreatedAt());
4671: $this->setVersionCreatedBy($version->getVersionCreatedBy());
4672:
4673: return $this;
4674: }
4675:
4676: 4677: 4678: 4679: 4680: 4681: 4682:
4683: public function getLastVersionNumber($con = null)
4684: {
4685: $v = CategoryVersionQuery::create()
4686: ->filterByCategory($this)
4687: ->orderByVersion('desc')
4688: ->findOne($con);
4689: if (!$v) {
4690: return 0;
4691: }
4692:
4693: return $v->getVersion();
4694: }
4695:
4696: 4697: 4698: 4699: 4700: 4701: 4702:
4703: public function isLastVersion($con = null)
4704: {
4705: return $this->getLastVersionNumber($con) == $this->getVersion();
4706: }
4707:
4708: 4709: 4710: 4711: 4712: 4713: 4714: 4715:
4716: public function getOneVersion($versionNumber, $con = null)
4717: {
4718: return CategoryVersionQuery::create()
4719: ->filterByCategory($this)
4720: ->filterByVersion($versionNumber)
4721: ->findOne($con);
4722: }
4723:
4724: 4725: 4726: 4727: 4728: 4729: 4730:
4731: public function getAllVersions($con = null)
4732: {
4733: $criteria = new Criteria();
4734: $criteria->addAscendingOrderByColumn(CategoryVersionPeer::VERSION);
4735:
4736: return $this->getCategoryVersions($criteria, $con);
4737: }
4738:
4739: 4740: 4741: 4742: 4743: 4744: 4745: 4746: 4747: 4748: 4749: 4750: 4751: 4752: 4753: 4754: 4755:
4756: public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
4757: {
4758: $fromVersion = $this->toArray();
4759: $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
4760:
4761: return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
4762: }
4763:
4764: 4765: 4766: 4767: 4768: 4769: 4770: 4771: 4772: 4773: 4774: 4775: 4776: 4777: 4778: 4779: 4780: 4781:
4782: public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
4783: {
4784: $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
4785: $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
4786:
4787: return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
4788: }
4789:
4790: 4791: 4792: 4793: 4794: 4795: 4796: 4797: 4798: 4799: 4800: 4801: 4802: 4803: 4804: 4805: 4806:
4807: protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
4808: {
4809: $fromVersionNumber = $fromVersion['Version'];
4810: $toVersionNumber = $toVersion['Version'];
4811: $ignoredColumns = array_merge(array(
4812: 'Version',
4813: 'VersionCreatedAt',
4814: 'VersionCreatedBy',
4815: ), $ignoredColumns);
4816: $diff = array();
4817: foreach ($fromVersion as $key => $value) {
4818: if (in_array($key, $ignoredColumns)) {
4819: continue;
4820: }
4821: if ($toVersion[$key] != $value) {
4822: switch ($keys) {
4823: case 'versions':
4824: $diff[$fromVersionNumber][$key] = $value;
4825: $diff[$toVersionNumber][$key] = $toVersion[$key];
4826: break;
4827: default:
4828: $diff[$key] = array(
4829: $fromVersionNumber => $value,
4830: $toVersionNumber => $toVersion[$key],
4831: );
4832: break;
4833: }
4834: }
4835: }
4836:
4837: return $diff;
4838: }
4839: 4840: 4841: 4842: 4843: 4844: 4845: 4846: 4847:
4848: public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null)
4849: {
4850: $criteria = CategoryVersionQuery::create(null, $criteria);
4851: $criteria->addDescendingOrderByColumn(CategoryVersionPeer::VERSION);
4852: $criteria->limit($number);
4853:
4854: return $this->getCategoryVersions($criteria, $con);
4855: }
4856: }
4857: