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