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