Overview

Namespaces

  • Thelia
    • Action
    • Config
    • Controller
    • Core
      • Bundle
      • DependencyInjection
        • Compiler
        • Loader
      • Event
      • EventListener
      • Template
        • BaseParam
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools
    • Tpex
      • BaseParam
      • Element
        • Loop
        • TestLoop
      • Event
      • Exception
      • Filter
      • Tokenizer

Classes

  • BaseAccessory
  • BaseAccessoryPeer
  • BaseAccessoryQuery
  • BaseAddress
  • BaseAddressPeer
  • BaseAddressQuery
  • BaseAdmin
  • BaseAdminGroup
  • BaseAdminGroupPeer
  • BaseAdminGroupQuery
  • BaseAdminLog
  • BaseAdminLogPeer
  • BaseAdminLogQuery
  • BaseAdminPeer
  • BaseAdminQuery
  • BaseArea
  • BaseAreaPeer
  • BaseAreaQuery
  • BaseAttribute
  • BaseAttributeAv
  • BaseAttributeAvI18n
  • BaseAttributeAvI18nPeer
  • BaseAttributeAvI18nQuery
  • BaseAttributeAvPeer
  • BaseAttributeAvQuery
  • BaseAttributeCategory
  • BaseAttributeCategoryPeer
  • BaseAttributeCategoryQuery
  • BaseAttributeCombination
  • BaseAttributeCombinationPeer
  • BaseAttributeCombinationQuery
  • BaseAttributeI18n
  • BaseAttributeI18nPeer
  • BaseAttributeI18nQuery
  • BaseAttributePeer
  • BaseAttributeQuery
  • BaseCategory
  • BaseCategoryI18n
  • BaseCategoryI18nPeer
  • BaseCategoryI18nQuery
  • BaseCategoryPeer
  • BaseCategoryQuery
  • BaseCategoryVersion
  • BaseCategoryVersionPeer
  • BaseCategoryVersionQuery
  • BaseCombination
  • BaseCombinationPeer
  • BaseCombinationQuery
  • BaseConfig
  • BaseConfigI18n
  • BaseConfigI18nPeer
  • BaseConfigI18nQuery
  • BaseConfigPeer
  • BaseConfigQuery
  • BaseContent
  • BaseContentAssoc
  • BaseContentAssocPeer
  • BaseContentAssocQuery
  • BaseContentFolder
  • BaseContentFolderPeer
  • BaseContentFolderQuery
  • BaseContentI18n
  • BaseContentI18nPeer
  • BaseContentI18nQuery
  • BaseContentPeer
  • BaseContentQuery
  • BaseContentVersion
  • BaseContentVersionPeer
  • BaseContentVersionQuery
  • BaseCountry
  • BaseCountryI18n
  • BaseCountryI18nPeer
  • BaseCountryI18nQuery
  • BaseCountryPeer
  • BaseCountryQuery
  • BaseCoupon
  • BaseCouponOrder
  • BaseCouponOrderPeer
  • BaseCouponOrderQuery
  • BaseCouponPeer
  • BaseCouponQuery
  • BaseCouponRule
  • BaseCouponRulePeer
  • BaseCouponRuleQuery
  • BaseCurrency
  • BaseCurrencyPeer
  • BaseCurrencyQuery
  • BaseCustomer
  • BaseCustomerPeer
  • BaseCustomerQuery
  • BaseCustomerTitle
  • BaseCustomerTitleI18n
  • BaseCustomerTitleI18nPeer
  • BaseCustomerTitleI18nQuery
  • BaseCustomerTitlePeer
  • BaseCustomerTitleQuery
  • BaseDelivzone
  • BaseDelivzonePeer
  • BaseDelivzoneQuery
  • BaseDocument
  • BaseDocumentI18n
  • BaseDocumentI18nPeer
  • BaseDocumentI18nQuery
  • BaseDocumentPeer
  • BaseDocumentQuery
  • BaseFeature
  • BaseFeatureAv
  • BaseFeatureAvI18n
  • BaseFeatureAvI18nPeer
  • BaseFeatureAvI18nQuery
  • BaseFeatureAvPeer
  • BaseFeatureAvQuery
  • BaseFeatureCategory
  • BaseFeatureCategoryPeer
  • BaseFeatureCategoryQuery
  • BaseFeatureI18n
  • BaseFeatureI18nPeer
  • BaseFeatureI18nQuery
  • BaseFeaturePeer
  • BaseFeatureProd
  • BaseFeatureProdPeer
  • BaseFeatureProdQuery
  • BaseFeatureQuery
  • BaseFolder
  • BaseFolderI18n
  • BaseFolderI18nPeer
  • BaseFolderI18nQuery
  • BaseFolderPeer
  • BaseFolderQuery
  • BaseFolderVersion
  • BaseFolderVersionPeer
  • BaseFolderVersionQuery
  • BaseGroup
  • BaseGroupI18n
  • BaseGroupI18nPeer
  • BaseGroupI18nQuery
  • BaseGroupModule
  • BaseGroupModulePeer
  • BaseGroupModuleQuery
  • BaseGroupPeer
  • BaseGroupQuery
  • BaseGroupResource
  • BaseGroupResourcePeer
  • BaseGroupResourceQuery
  • BaseImage
  • BaseImageI18n
  • BaseImageI18nPeer
  • BaseImageI18nQuery
  • BaseImagePeer
  • BaseImageQuery
  • BaseLang
  • BaseLangPeer
  • BaseLangQuery
  • BaseMessage
  • BaseMessageI18n
  • BaseMessageI18nPeer
  • BaseMessageI18nQuery
  • BaseMessagePeer
  • BaseMessageQuery
  • BaseMessageVersion
  • BaseMessageVersionPeer
  • BaseMessageVersionQuery
  • BaseModule
  • BaseModuleI18n
  • BaseModuleI18nPeer
  • BaseModuleI18nQuery
  • BaseModulePeer
  • BaseModuleQuery
  • BaseOrder
  • BaseOrderAddress
  • BaseOrderAddressPeer
  • BaseOrderAddressQuery
  • BaseOrderFeature
  • BaseOrderFeaturePeer
  • BaseOrderFeatureQuery
  • BaseOrderPeer
  • BaseOrderProduct
  • BaseOrderProductPeer
  • BaseOrderProductQuery
  • BaseOrderQuery
  • BaseOrderStatus
  • BaseOrderStatusI18n
  • BaseOrderStatusI18nPeer
  • BaseOrderStatusI18nQuery
  • BaseOrderStatusPeer
  • BaseOrderStatusQuery
  • BaseProduct
  • BaseProductCategory
  • BaseProductCategoryPeer
  • BaseProductCategoryQuery
  • BaseProductI18n
  • BaseProductI18nPeer
  • BaseProductI18nQuery
  • BaseProductPeer
  • BaseProductQuery
  • BaseProductVersion
  • BaseProductVersionPeer
  • BaseProductVersionQuery
  • BaseResource
  • BaseResourceI18n
  • BaseResourceI18nPeer
  • BaseResourceI18nQuery
  • BaseResourcePeer
  • BaseResourceQuery
  • BaseRewriting
  • BaseRewritingPeer
  • BaseRewritingQuery
  • BaseStock
  • BaseStockPeer
  • BaseStockQuery
  • BaseTax
  • BaseTaxI18n
  • BaseTaxI18nPeer
  • BaseTaxI18nQuery
  • BaseTaxPeer
  • BaseTaxQuery
  • BaseTaxRule
  • BaseTaxRuleCountry
  • BaseTaxRuleCountryPeer
  • BaseTaxRuleCountryQuery
  • BaseTaxRuleI18n
  • BaseTaxRuleI18nPeer
  • BaseTaxRuleI18nQuery
  • BaseTaxRulePeer
  • BaseTaxRuleQuery
  • Overview
  • Namespace
  • Class
  • Tree
   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:  * Base class that represents a row from the 'attribute' table.
  32:  *
  33:  *
  34:  *
  35:  * @package    propel.generator.Thelia.Model.om
  36:  */
  37: abstract class BaseAttribute extends BaseObject implements Persistent
  38: {
  39:     /**
  40:      * Peer class name
  41:      */
  42:     const PEER = 'Thelia\\Model\\AttributePeer';
  43: 
  44:     /**
  45:      * The Peer class.
  46:      * Instance provides a convenient way of calling static methods on a class
  47:      * that calling code may not be able to identify.
  48:      * @var        AttributePeer
  49:      */
  50:     protected static $peer;
  51: 
  52:     /**
  53:      * The flag var to prevent infinit loop in deep copy
  54:      * @var       boolean
  55:      */
  56:     protected $startCopy = false;
  57: 
  58:     /**
  59:      * The value for the id field.
  60:      * @var        int
  61:      */
  62:     protected $id;
  63: 
  64:     /**
  65:      * The value for the position field.
  66:      * @var        int
  67:      */
  68:     protected $position;
  69: 
  70:     /**
  71:      * The value for the created_at field.
  72:      * @var        string
  73:      */
  74:     protected $created_at;
  75: 
  76:     /**
  77:      * The value for the updated_at field.
  78:      * @var        string
  79:      */
  80:     protected $updated_at;
  81: 
  82:     /**
  83:      * @var        PropelObjectCollection|AttributeAv[] Collection to store aggregation of AttributeAv objects.
  84:      */
  85:     protected $collAttributeAvs;
  86:     protected $collAttributeAvsPartial;
  87: 
  88:     /**
  89:      * @var        PropelObjectCollection|AttributeCombination[] Collection to store aggregation of AttributeCombination objects.
  90:      */
  91:     protected $collAttributeCombinations;
  92:     protected $collAttributeCombinationsPartial;
  93: 
  94:     /**
  95:      * @var        PropelObjectCollection|AttributeCategory[] Collection to store aggregation of AttributeCategory objects.
  96:      */
  97:     protected $collAttributeCategorys;
  98:     protected $collAttributeCategorysPartial;
  99: 
 100:     /**
 101:      * @var        PropelObjectCollection|AttributeI18n[] Collection to store aggregation of AttributeI18n objects.
 102:      */
 103:     protected $collAttributeI18ns;
 104:     protected $collAttributeI18nsPartial;
 105: 
 106:     /**
 107:      * Flag to prevent endless save loop, if this object is referenced
 108:      * by another object which falls in this transaction.
 109:      * @var        boolean
 110:      */
 111:     protected $alreadyInSave = false;
 112: 
 113:     /**
 114:      * Flag to prevent endless validation loop, if this object is referenced
 115:      * by another object which falls in this transaction.
 116:      * @var        boolean
 117:      */
 118:     protected $alreadyInValidation = false;
 119: 
 120:     /**
 121:      * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced
 122:      * @var        boolean
 123:      */
 124:     protected $alreadyInClearAllReferencesDeep = false;
 125: 
 126:     // i18n behavior
 127: 
 128:     /**
 129:      * Current locale
 130:      * @var        string
 131:      */
 132:     protected $currentLocale = 'en_US';
 133: 
 134:     /**
 135:      * Current translation objects
 136:      * @var        array[AttributeI18n]
 137:      */
 138:     protected $currentTranslations;
 139: 
 140:     /**
 141:      * An array of objects scheduled for deletion.
 142:      * @var     PropelObjectCollection
 143:      */
 144:     protected $attributeAvsScheduledForDeletion = null;
 145: 
 146:     /**
 147:      * An array of objects scheduled for deletion.
 148:      * @var     PropelObjectCollection
 149:      */
 150:     protected $attributeCombinationsScheduledForDeletion = null;
 151: 
 152:     /**
 153:      * An array of objects scheduled for deletion.
 154:      * @var     PropelObjectCollection
 155:      */
 156:     protected $attributeCategorysScheduledForDeletion = null;
 157: 
 158:     /**
 159:      * An array of objects scheduled for deletion.
 160:      * @var     PropelObjectCollection
 161:      */
 162:     protected $attributeI18nsScheduledForDeletion = null;
 163: 
 164:     /**
 165:      * Get the [id] column value.
 166:      *
 167:      * @return int
 168:      */
 169:     public function getId()
 170:     {
 171:         return $this->id;
 172:     }
 173: 
 174:     /**
 175:      * Get the [position] column value.
 176:      *
 177:      * @return int
 178:      */
 179:     public function getPosition()
 180:     {
 181:         return $this->position;
 182:     }
 183: 
 184:     /**
 185:      * Get the [optionally formatted] temporal [created_at] column value.
 186:      *
 187:      *
 188:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 189:      *               If format is null, then the raw DateTime object will be returned.
 190:      * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
 191:      * @throws PropelException - if unable to parse/validate the date/time value.
 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:             // while technically this is not a default value of null,
 201:             // this seems to be closest in meaning.
 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:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 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:      * Get the [optionally formatted] temporal [updated_at] column value.
 226:      *
 227:      *
 228:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 229:      *               If format is null, then the raw DateTime object will be returned.
 230:      * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
 231:      * @throws PropelException - if unable to parse/validate the date/time value.
 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:             // while technically this is not a default value of null,
 241:             // this seems to be closest in meaning.
 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:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 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:      * Set the value of [id] column.
 266:      *
 267:      * @param int $v new value
 268:      * @return Attribute The current object (for fluent API support)
 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:     } // setId()
 284: 
 285:     /**
 286:      * Set the value of [position] column.
 287:      *
 288:      * @param int $v new value
 289:      * @return Attribute The current object (for fluent API support)
 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:     } // setPosition()
 305: 
 306:     /**
 307:      * Sets the value of [created_at] column to a normalized version of the date/time value specified.
 308:      *
 309:      * @param mixed $v string, integer (timestamp), or DateTime value.
 310:      *               Empty strings are treated as null.
 311:      * @return Attribute The current object (for fluent API support)
 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:         } // if either are not null
 324: 
 325: 
 326:         return $this;
 327:     } // setCreatedAt()
 328: 
 329:     /**
 330:      * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
 331:      *
 332:      * @param mixed $v string, integer (timestamp), or DateTime value.
 333:      *               Empty strings are treated as null.
 334:      * @return Attribute The current object (for fluent API support)
 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:         } // if either are not null
 347: 
 348: 
 349:         return $this;
 350:     } // setUpdatedAt()
 351: 
 352:     /**
 353:      * Indicates whether the columns in this object are only set to default values.
 354:      *
 355:      * This method can be used in conjunction with isModified() to indicate whether an object is both
 356:      * modified _and_ has some values set which are non-default.
 357:      *
 358:      * @return boolean Whether the columns in this object are only been set with default values.
 359:      */
 360:     public function hasOnlyDefaultValues()
 361:     {
 362:         // otherwise, everything was equal, so return true
 363:         return true;
 364:     } // hasOnlyDefaultValues()
 365: 
 366:     /**
 367:      * Hydrates (populates) the object variables with values from the database resultset.
 368:      *
 369:      * An offset (0-based "start column") is specified so that objects can be hydrated
 370:      * with a subset of the columns in the resultset rows.  This is needed, for example,
 371:      * for results of JOIN queries where the resultset row includes columns from two or
 372:      * more tables.
 373:      *
 374:      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
 375:      * @param int $startcol 0-based offset column which indicates which restultset column to start with.
 376:      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
 377:      * @return int             next starting column
 378:      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
 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; // 4 = AttributePeer::NUM_HYDRATE_COLUMNS.
 397: 
 398:         } catch (Exception $e) {
 399:             throw new PropelException("Error populating Attribute object", $e);
 400:         }
 401:     }
 402: 
 403:     /**
 404:      * Checks and repairs the internal consistency of the object.
 405:      *
 406:      * This method is executed after an already-instantiated object is re-hydrated
 407:      * from the database.  It exists to check any foreign keys to make sure that
 408:      * the objects related to the current object are correct based on foreign key.
 409:      *
 410:      * You can override this method in the stub class, but you should always invoke
 411:      * the base method from the overridden method (i.e. parent::ensureConsistency()),
 412:      * in case your model changes.
 413:      *
 414:      * @throws PropelException
 415:      */
 416:     public function ensureConsistency()
 417:     {
 418: 
 419:     } // ensureConsistency
 420: 
 421:     /**
 422:      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
 423:      *
 424:      * This will only work if the object has been saved and has a valid primary key set.
 425:      *
 426:      * @param boolean $deep (optional) Whether to also de-associated any related objects.
 427:      * @param PropelPDO $con (optional) The PropelPDO connection to use.
 428:      * @return void
 429:      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
 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:         // We don't need to alter the object instance pool; we're just modifying this instance
 446:         // already in the pool.
 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); // rehydrate
 455: 
 456:         if ($deep) {  // also de-associate any related objects?
 457: 
 458:             $this->collAttributeAvs = null;
 459: 
 460:             $this->collAttributeCombinations = null;
 461: 
 462:             $this->collAttributeCategorys = null;
 463: 
 464:             $this->collAttributeI18ns = null;
 465: 
 466:         } // if (deep)
 467:     }
 468: 
 469:     /**
 470:      * Removes this object from datastore and sets delete attribute.
 471:      *
 472:      * @param PropelPDO $con
 473:      * @return void
 474:      * @throws PropelException
 475:      * @throws Exception
 476:      * @see        BaseObject::setDeleted()
 477:      * @see        BaseObject::isDeleted()
 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:      * Persists this object to the database.
 510:      *
 511:      * If the object is new, it inserts it; otherwise an update is performed.
 512:      * All modified related objects will also be persisted in the doSave()
 513:      * method.  This method wraps all precipitate database operations in a
 514:      * single transaction.
 515:      *
 516:      * @param PropelPDO $con
 517:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 518:      * @throws PropelException
 519:      * @throws Exception
 520:      * @see        doSave()
 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:                 // timestampable behavior
 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:                 // timestampable behavior
 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:      * Performs the work of inserting or updating the row in the database.
 575:      *
 576:      * If the object is new, it inserts it; otherwise an update is performed.
 577:      * All related objects are also updated in this method.
 578:      *
 579:      * @param PropelPDO $con
 580:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 581:      * @throws PropelException
 582:      * @see        save()
 583:      */
 584:     protected function doSave(PropelPDO $con)
 585:     {
 586:         $affectedRows = 0; // initialize var to track total num of affected rows
 587:         if (!$this->alreadyInSave) {
 588:             $this->alreadyInSave = true;
 589: 
 590:             if ($this->isNew() || $this->isModified()) {
 591:                 // persist changes
 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:     } // doSave()
 675: 
 676:     /**
 677:      * Insert the row in the database.
 678:      *
 679:      * @param PropelPDO $con
 680:      *
 681:      * @throws PropelException
 682:      * @see        doSave()
 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:          // check the columns in natural order for more readable SQL queries
 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:      * Update the row in the database.
 750:      *
 751:      * @param PropelPDO $con
 752:      *
 753:      * @see        doSave()
 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:      * Array of ValidationFailed objects.
 764:      * @var        array ValidationFailed[]
 765:      */
 766:     protected $validationFailures = array();
 767: 
 768:     /**
 769:      * Gets any ValidationFailed objects that resulted from last call to validate().
 770:      *
 771:      *
 772:      * @return array ValidationFailed[]
 773:      * @see        validate()
 774:      */
 775:     public function getValidationFailures()
 776:     {
 777:         return $this->validationFailures;
 778:     }
 779: 
 780:     /**
 781:      * Validates the objects modified field values and all objects related to this table.
 782:      *
 783:      * If $columns is either a column name or an array of column names
 784:      * only those columns are validated.
 785:      *
 786:      * @param mixed $columns Column name or an array of column names.
 787:      * @return boolean Whether all columns pass validation.
 788:      * @see        doValidate()
 789:      * @see        getValidationFailures()
 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:      * This function performs the validation work for complex object models.
 807:      *
 808:      * In addition to checking the current object, all related objects will
 809:      * also be validated.  If all pass then <code>true</code> is returned; otherwise
 810:      * an aggreagated array of ValidationFailed objects will be returned.
 811:      *
 812:      * @param array $columns Array of column names to validate.
 813:      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
 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:      * Retrieves a field from the object by name passed in as a string.
 870:      *
 871:      * @param string $name name
 872:      * @param string $type The type of fieldname the $name is of:
 873:      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
 874:      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
 875:      *               Defaults to BasePeer::TYPE_PHPNAME
 876:      * @return mixed Value of field.
 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:      * Retrieves a field from the object by Position as specified in the xml schema.
 888:      * Zero-based.
 889:      *
 890:      * @param int $pos position in xml schema
 891:      * @return mixed Value of field at $pos
 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:         } // switch()
 912:     }
 913: 
 914:     /**
 915:      * Exports the object as an array.
 916:      *
 917:      * You can specify the key type of the array by passing one of the class
 918:      * type constants.
 919:      *
 920:      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
 921:      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
 922:      *                    Defaults to BasePeer::TYPE_PHPNAME.
 923:      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
 924:      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
 925:      * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
 926:      *
 927:      * @return array an associative array containing the field names (as keys) and field values
 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:      * Sets a field from the object by name passed in as a string.
 962:      *
 963:      * @param string $name peer name
 964:      * @param mixed $value field value
 965:      * @param string $type The type of fieldname the $name is of:
 966:      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
 967:      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
 968:      *                     Defaults to BasePeer::TYPE_PHPNAME
 969:      * @return void
 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:      * Sets a field from the object by Position as specified in the xml schema.
 980:      * Zero-based.
 981:      *
 982:      * @param int $pos position in xml schema
 983:      * @param mixed $value field value
 984:      * @return void
 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:         } // switch()
1002:     }
1003: 
1004:     /**
1005:      * Populates the object using an array.
1006:      *
1007:      * This is particularly useful when populating an object from one of the
1008:      * request arrays (e.g. $_POST).  This method goes through the column
1009:      * names, checking to see whether a matching key exists in populated
1010:      * array. If so the setByName() method is called for that column.
1011:      *
1012:      * You can specify the key type of the array by additionally passing one
1013:      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1014:      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1015:      * The default key type is the column's BasePeer::TYPE_PHPNAME
1016:      *
1017:      * @param array  $arr     An array to populate the object from.
1018:      * @param string $keyType The type of keys the array uses.
1019:      * @return void
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:      * Build a Criteria object containing the values of all modified columns in this object.
1033:      *
1034:      * @return Criteria The Criteria object containing all modified values.
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:      * Builds a Criteria object containing the primary key for this object.
1050:      *
1051:      * Unlike buildCriteria() this method includes the primary key values regardless
1052:      * of whether or not they have been modified.
1053:      *
1054:      * @return Criteria The Criteria object containing value(s) for primary key(s).
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:      * Returns the primary key for this object (row).
1066:      * @return int
1067:      */
1068:     public function getPrimaryKey()
1069:     {
1070:         return $this->getId();
1071:     }
1072: 
1073:     /**
1074:      * Generic method to set the primary key (id column).
1075:      *
1076:      * @param  int $key Primary key.
1077:      * @return void
1078:      */
1079:     public function setPrimaryKey($key)
1080:     {
1081:         $this->setId($key);
1082:     }
1083: 
1084:     /**
1085:      * Returns true if the primary key for this object is null.
1086:      * @return boolean
1087:      */
1088:     public function isPrimaryKeyNull()
1089:     {
1090: 
1091:         return null === $this->getId();
1092:     }
1093: 
1094:     /**
1095:      * Sets contents of passed object to values from current object.
1096:      *
1097:      * If desired, this method can also make copies of all associated (fkey referrers)
1098:      * objects.
1099:      *
1100:      * @param object $copyObj An object of Attribute (or compatible) type.
1101:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1102:      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1103:      * @throws PropelException
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:             // important: temporarily setNew(false) because this affects the behavior of
1113:             // the getter/setter methods for fkey referrer objects.
1114:             $copyObj->setNew(false);
1115:             // store object hash to prevent cycle
1116:             $this->startCopy = true;
1117: 
1118:             foreach ($this->getAttributeAvs() as $relObj) {
1119:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1120:                     $copyObj->addAttributeAv($relObj->copy($deepCopy));
1121:                 }
1122:             }
1123: 
1124:             foreach ($this->getAttributeCombinations() as $relObj) {
1125:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1126:                     $copyObj->addAttributeCombination($relObj->copy($deepCopy));
1127:                 }
1128:             }
1129: 
1130:             foreach ($this->getAttributeCategorys() as $relObj) {
1131:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1132:                     $copyObj->addAttributeCategory($relObj->copy($deepCopy));
1133:                 }
1134:             }
1135: 
1136:             foreach ($this->getAttributeI18ns() as $relObj) {
1137:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1138:                     $copyObj->addAttributeI18n($relObj->copy($deepCopy));
1139:                 }
1140:             }
1141: 
1142:             //unflag object copy
1143:             $this->startCopy = false;
1144:         } // if ($deepCopy)
1145: 
1146:         if ($makeNew) {
1147:             $copyObj->setNew(true);
1148:             $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
1149:         }
1150:     }
1151: 
1152:     /**
1153:      * Makes a copy of this object that will be inserted as a new row in table when saved.
1154:      * It creates a new object filling in the simple attributes, but skipping any primary
1155:      * keys that are defined for the table.
1156:      *
1157:      * If desired, this method can also make copies of all associated (fkey referrers)
1158:      * objects.
1159:      *
1160:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1161:      * @return Attribute Clone of current object.
1162:      * @throws PropelException
1163:      */
1164:     public function copy($deepCopy = false)
1165:     {
1166:         // we use get_class(), because this might be a subclass
1167:         $clazz = get_class($this);
1168:         $copyObj = new $clazz();
1169:         $this->copyInto($copyObj, $deepCopy);
1170: 
1171:         return $copyObj;
1172:     }
1173: 
1174:     /**
1175:      * Returns a peer instance associated with this om.
1176:      *
1177:      * Since Peer classes are not to have any instance attributes, this method returns the
1178:      * same instance for all member of this class. The method could therefore
1179:      * be static, but this would prevent one from overriding the behavior.
1180:      *
1181:      * @return AttributePeer
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:      * Initializes a collection based on the name of a relation.
1195:      * Avoids crafting an 'init[$relationName]s' method name
1196:      * that wouldn't work when StandardEnglishPluralizer is used.
1197:      *
1198:      * @param string $relationName The name of the relation to initialize
1199:      * @return void
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:      * Clears out the collAttributeAvs collection
1219:      *
1220:      * This does not modify the database; however, it will remove any associated objects, causing
1221:      * them to be refetched by subsequent calls to accessor method.
1222:      *
1223:      * @return Attribute The current object (for fluent API support)
1224:      * @see        addAttributeAvs()
1225:      */
1226:     public function clearAttributeAvs()
1227:     {
1228:         $this->collAttributeAvs = null; // important to set this to null since that means it is uninitialized
1229:         $this->collAttributeAvsPartial = null;
1230: 
1231:         return $this;
1232:     }
1233: 
1234:     /**
1235:      * reset is the collAttributeAvs collection loaded partially
1236:      *
1237:      * @return void
1238:      */
1239:     public function resetPartialAttributeAvs($v = true)
1240:     {
1241:         $this->collAttributeAvsPartial = $v;
1242:     }
1243: 
1244:     /**
1245:      * Initializes the collAttributeAvs collection.
1246:      *
1247:      * By default this just sets the collAttributeAvs collection to an empty array (like clearcollAttributeAvs());
1248:      * however, you may wish to override this method in your stub class to provide setting appropriate
1249:      * to your application -- for example, setting the initial array to the values stored in database.
1250:      *
1251:      * @param boolean $overrideExisting If set to true, the method call initializes
1252:      *                                        the collection even if it is not empty
1253:      *
1254:      * @return void
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:      * Gets an array of AttributeAv objects which contain a foreign key that references this object.
1267:      *
1268:      * If the $criteria is not null, it is used to always fetch the results from the database.
1269:      * Otherwise the results are fetched from the database the first time, then cached.
1270:      * Next time the same method is called without $criteria, the cached collection is returned.
1271:      * If this Attribute is new, it will return
1272:      * an empty collection or the current collection; the criteria is ignored on a new object.
1273:      *
1274:      * @param Criteria $criteria optional Criteria object to narrow the query
1275:      * @param PropelPDO $con optional connection object
1276:      * @return PropelObjectCollection|AttributeAv[] List of AttributeAv objects
1277:      * @throws PropelException
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:                 // return empty collection
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:      * Sets a collection of AttributeAv objects related by a one-to-many relationship
1325:      * to the current object.
1326:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1327:      * and new objects from the given Propel collection.
1328:      *
1329:      * @param PropelCollection $attributeAvs A Propel collection.
1330:      * @param PropelPDO $con Optional connection object
1331:      * @return Attribute The current object (for fluent API support)
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:      * Returns the number of related AttributeAv objects.
1356:      *
1357:      * @param Criteria $criteria
1358:      * @param boolean $distinct
1359:      * @param PropelPDO $con
1360:      * @return int             Count of related AttributeAv objects.
1361:      * @throws PropelException
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:      * Method called to associate a AttributeAv object to this object
1389:      * through the AttributeAv foreign key attribute.
1390:      *
1391:      * @param    AttributeAv $l AttributeAv
1392:      * @return Attribute The current object (for fluent API support)
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)) { // only add it if the **same** object is not already associated
1401:             $this->doAddAttributeAv($l);
1402:         }
1403: 
1404:         return $this;
1405:     }
1406: 
1407:     /**
1408:      * @param   AttributeAv $attributeAv The attributeAv object to add.
1409:      */
1410:     protected function doAddAttributeAv($attributeAv)
1411:     {
1412:         $this->collAttributeAvs[]= $attributeAv;
1413:         $attributeAv->setAttribute($this);
1414:     }
1415: 
1416:     /**
1417:      * @param   AttributeAv $attributeAv The attributeAv object to remove.
1418:      * @return Attribute The current object (for fluent API support)
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:      * Clears out the collAttributeCombinations collection
1437:      *
1438:      * This does not modify the database; however, it will remove any associated objects, causing
1439:      * them to be refetched by subsequent calls to accessor method.
1440:      *
1441:      * @return Attribute The current object (for fluent API support)
1442:      * @see        addAttributeCombinations()
1443:      */
1444:     public function clearAttributeCombinations()
1445:     {
1446:         $this->collAttributeCombinations = null; // important to set this to null since that means it is uninitialized
1447:         $this->collAttributeCombinationsPartial = null;
1448: 
1449:         return $this;
1450:     }
1451: 
1452:     /**
1453:      * reset is the collAttributeCombinations collection loaded partially
1454:      *
1455:      * @return void
1456:      */
1457:     public function resetPartialAttributeCombinations($v = true)
1458:     {
1459:         $this->collAttributeCombinationsPartial = $v;
1460:     }
1461: 
1462:     /**
1463:      * Initializes the collAttributeCombinations collection.
1464:      *
1465:      * By default this just sets the collAttributeCombinations collection to an empty array (like clearcollAttributeCombinations());
1466:      * however, you may wish to override this method in your stub class to provide setting appropriate
1467:      * to your application -- for example, setting the initial array to the values stored in database.
1468:      *
1469:      * @param boolean $overrideExisting If set to true, the method call initializes
1470:      *                                        the collection even if it is not empty
1471:      *
1472:      * @return void
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:      * Gets an array of AttributeCombination objects which contain a foreign key that references this object.
1485:      *
1486:      * If the $criteria is not null, it is used to always fetch the results from the database.
1487:      * Otherwise the results are fetched from the database the first time, then cached.
1488:      * Next time the same method is called without $criteria, the cached collection is returned.
1489:      * If this Attribute is new, it will return
1490:      * an empty collection or the current collection; the criteria is ignored on a new object.
1491:      *
1492:      * @param Criteria $criteria optional Criteria object to narrow the query
1493:      * @param PropelPDO $con optional connection object
1494:      * @return PropelObjectCollection|AttributeCombination[] List of AttributeCombination objects
1495:      * @throws PropelException
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:                 // return empty collection
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:      * Sets a collection of AttributeCombination objects related by a one-to-many relationship
1543:      * to the current object.
1544:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1545:      * and new objects from the given Propel collection.
1546:      *
1547:      * @param PropelCollection $attributeCombinations A Propel collection.
1548:      * @param PropelPDO $con Optional connection object
1549:      * @return Attribute The current object (for fluent API support)
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:      * Returns the number of related AttributeCombination objects.
1574:      *
1575:      * @param Criteria $criteria
1576:      * @param boolean $distinct
1577:      * @param PropelPDO $con
1578:      * @return int             Count of related AttributeCombination objects.
1579:      * @throws PropelException
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:      * Method called to associate a AttributeCombination object to this object
1607:      * through the AttributeCombination foreign key attribute.
1608:      *
1609:      * @param    AttributeCombination $l AttributeCombination
1610:      * @return Attribute The current object (for fluent API support)
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)) { // only add it if the **same** object is not already associated
1619:             $this->doAddAttributeCombination($l);
1620:         }
1621: 
1622:         return $this;
1623:     }
1624: 
1625:     /**
1626:      * @param   AttributeCombination $attributeCombination The attributeCombination object to add.
1627:      */
1628:     protected function doAddAttributeCombination($attributeCombination)
1629:     {
1630:         $this->collAttributeCombinations[]= $attributeCombination;
1631:         $attributeCombination->setAttribute($this);
1632:     }
1633: 
1634:     /**
1635:      * @param   AttributeCombination $attributeCombination The attributeCombination object to remove.
1636:      * @return Attribute The current object (for fluent API support)
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:      * If this collection has already been initialized with
1656:      * an identical criteria, it returns the collection.
1657:      * Otherwise if this Attribute is new, it will return
1658:      * an empty collection; or if this Attribute has previously
1659:      * been saved, it will retrieve related AttributeCombinations from storage.
1660:      *
1661:      * This method is protected by default in order to keep the public
1662:      * api reasonable.  You can provide public methods for those you
1663:      * actually need in Attribute.
1664:      *
1665:      * @param Criteria $criteria optional Criteria object to narrow the query
1666:      * @param PropelPDO $con optional connection object
1667:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1668:      * @return PropelObjectCollection|AttributeCombination[] List of AttributeCombination objects
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:      * If this collection has already been initialized with
1681:      * an identical criteria, it returns the collection.
1682:      * Otherwise if this Attribute is new, it will return
1683:      * an empty collection; or if this Attribute has previously
1684:      * been saved, it will retrieve related AttributeCombinations from storage.
1685:      *
1686:      * This method is protected by default in order to keep the public
1687:      * api reasonable.  You can provide public methods for those you
1688:      * actually need in Attribute.
1689:      *
1690:      * @param Criteria $criteria optional Criteria object to narrow the query
1691:      * @param PropelPDO $con optional connection object
1692:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1693:      * @return PropelObjectCollection|AttributeCombination[] List of AttributeCombination objects
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:      * Clears out the collAttributeCategorys collection
1705:      *
1706:      * This does not modify the database; however, it will remove any associated objects, causing
1707:      * them to be refetched by subsequent calls to accessor method.
1708:      *
1709:      * @return Attribute The current object (for fluent API support)
1710:      * @see        addAttributeCategorys()
1711:      */
1712:     public function clearAttributeCategorys()
1713:     {
1714:         $this->collAttributeCategorys = null; // important to set this to null since that means it is uninitialized
1715:         $this->collAttributeCategorysPartial = null;
1716: 
1717:         return $this;
1718:     }
1719: 
1720:     /**
1721:      * reset is the collAttributeCategorys collection loaded partially
1722:      *
1723:      * @return void
1724:      */
1725:     public function resetPartialAttributeCategorys($v = true)
1726:     {
1727:         $this->collAttributeCategorysPartial = $v;
1728:     }
1729: 
1730:     /**
1731:      * Initializes the collAttributeCategorys collection.
1732:      *
1733:      * By default this just sets the collAttributeCategorys collection to an empty array (like clearcollAttributeCategorys());
1734:      * however, you may wish to override this method in your stub class to provide setting appropriate
1735:      * to your application -- for example, setting the initial array to the values stored in database.
1736:      *
1737:      * @param boolean $overrideExisting If set to true, the method call initializes
1738:      *                                        the collection even if it is not empty
1739:      *
1740:      * @return void
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:      * Gets an array of AttributeCategory objects which contain a foreign key that references this object.
1753:      *
1754:      * If the $criteria is not null, it is used to always fetch the results from the database.
1755:      * Otherwise the results are fetched from the database the first time, then cached.
1756:      * Next time the same method is called without $criteria, the cached collection is returned.
1757:      * If this Attribute is new, it will return
1758:      * an empty collection or the current collection; the criteria is ignored on a new object.
1759:      *
1760:      * @param Criteria $criteria optional Criteria object to narrow the query
1761:      * @param PropelPDO $con optional connection object
1762:      * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects
1763:      * @throws PropelException
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:                 // return empty collection
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:      * Sets a collection of AttributeCategory objects related by a one-to-many relationship
1811:      * to the current object.
1812:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1813:      * and new objects from the given Propel collection.
1814:      *
1815:      * @param PropelCollection $attributeCategorys A Propel collection.
1816:      * @param PropelPDO $con Optional connection object
1817:      * @return Attribute The current object (for fluent API support)
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:      * Returns the number of related AttributeCategory objects.
1842:      *
1843:      * @param Criteria $criteria
1844:      * @param boolean $distinct
1845:      * @param PropelPDO $con
1846:      * @return int             Count of related AttributeCategory objects.
1847:      * @throws PropelException
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:      * Method called to associate a AttributeCategory object to this object
1875:      * through the AttributeCategory foreign key attribute.
1876:      *
1877:      * @param    AttributeCategory $l AttributeCategory
1878:      * @return Attribute The current object (for fluent API support)
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)) { // only add it if the **same** object is not already associated
1887:             $this->doAddAttributeCategory($l);
1888:         }
1889: 
1890:         return $this;
1891:     }
1892: 
1893:     /**
1894:      * @param   AttributeCategory $attributeCategory The attributeCategory object to add.
1895:      */
1896:     protected function doAddAttributeCategory($attributeCategory)
1897:     {
1898:         $this->collAttributeCategorys[]= $attributeCategory;
1899:         $attributeCategory->setAttribute($this);
1900:     }
1901: 
1902:     /**
1903:      * @param   AttributeCategory $attributeCategory The attributeCategory object to remove.
1904:      * @return Attribute The current object (for fluent API support)
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:      * If this collection has already been initialized with
1924:      * an identical criteria, it returns the collection.
1925:      * Otherwise if this Attribute is new, it will return
1926:      * an empty collection; or if this Attribute has previously
1927:      * been saved, it will retrieve related AttributeCategorys from storage.
1928:      *
1929:      * This method is protected by default in order to keep the public
1930:      * api reasonable.  You can provide public methods for those you
1931:      * actually need in Attribute.
1932:      *
1933:      * @param Criteria $criteria optional Criteria object to narrow the query
1934:      * @param PropelPDO $con optional connection object
1935:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1936:      * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects
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:      * Clears out the collAttributeI18ns collection
1948:      *
1949:      * This does not modify the database; however, it will remove any associated objects, causing
1950:      * them to be refetched by subsequent calls to accessor method.
1951:      *
1952:      * @return Attribute The current object (for fluent API support)
1953:      * @see        addAttributeI18ns()
1954:      */
1955:     public function clearAttributeI18ns()
1956:     {
1957:         $this->collAttributeI18ns = null; // important to set this to null since that means it is uninitialized
1958:         $this->collAttributeI18nsPartial = null;
1959: 
1960:         return $this;
1961:     }
1962: 
1963:     /**
1964:      * reset is the collAttributeI18ns collection loaded partially
1965:      *
1966:      * @return void
1967:      */
1968:     public function resetPartialAttributeI18ns($v = true)
1969:     {
1970:         $this->collAttributeI18nsPartial = $v;
1971:     }
1972: 
1973:     /**
1974:      * Initializes the collAttributeI18ns collection.
1975:      *
1976:      * By default this just sets the collAttributeI18ns collection to an empty array (like clearcollAttributeI18ns());
1977:      * however, you may wish to override this method in your stub class to provide setting appropriate
1978:      * to your application -- for example, setting the initial array to the values stored in database.
1979:      *
1980:      * @param boolean $overrideExisting If set to true, the method call initializes
1981:      *                                        the collection even if it is not empty
1982:      *
1983:      * @return void
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:      * Gets an array of AttributeI18n objects which contain a foreign key that references this object.
1996:      *
1997:      * If the $criteria is not null, it is used to always fetch the results from the database.
1998:      * Otherwise the results are fetched from the database the first time, then cached.
1999:      * Next time the same method is called without $criteria, the cached collection is returned.
2000:      * If this Attribute is new, it will return
2001:      * an empty collection or the current collection; the criteria is ignored on a new object.
2002:      *
2003:      * @param Criteria $criteria optional Criteria object to narrow the query
2004:      * @param PropelPDO $con optional connection object
2005:      * @return PropelObjectCollection|AttributeI18n[] List of AttributeI18n objects
2006:      * @throws PropelException
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:                 // return empty collection
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:      * Sets a collection of AttributeI18n objects related by a one-to-many relationship
2054:      * to the current object.
2055:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2056:      * and new objects from the given Propel collection.
2057:      *
2058:      * @param PropelCollection $attributeI18ns A Propel collection.
2059:      * @param PropelPDO $con Optional connection object
2060:      * @return Attribute The current object (for fluent API support)
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:      * Returns the number of related AttributeI18n objects.
2085:      *
2086:      * @param Criteria $criteria
2087:      * @param boolean $distinct
2088:      * @param PropelPDO $con
2089:      * @return int             Count of related AttributeI18n objects.
2090:      * @throws PropelException
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:      * Method called to associate a AttributeI18n object to this object
2118:      * through the AttributeI18n foreign key attribute.
2119:      *
2120:      * @param    AttributeI18n $l AttributeI18n
2121:      * @return Attribute The current object (for fluent API support)
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)) { // only add it if the **same** object is not already associated
2134:             $this->doAddAttributeI18n($l);
2135:         }
2136: 
2137:         return $this;
2138:     }
2139: 
2140:     /**
2141:      * @param   AttributeI18n $attributeI18n The attributeI18n object to add.
2142:      */
2143:     protected function doAddAttributeI18n($attributeI18n)
2144:     {
2145:         $this->collAttributeI18ns[]= $attributeI18n;
2146:         $attributeI18n->setAttribute($this);
2147:     }
2148: 
2149:     /**
2150:      * @param   AttributeI18n $attributeI18n The attributeI18n object to remove.
2151:      * @return Attribute The current object (for fluent API support)
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:      * Clears the current object and sets all attributes to their default values
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:      * Resets all references to other model objects or collections of model objects.
2188:      *
2189:      * This method is a user-space workaround for PHP's inability to garbage collect
2190:      * objects with circular references (even in PHP 5.3). This is currently necessary
2191:      * when using Propel in certain daemon or large-volumne/high-memory operations.
2192:      *
2193:      * @param boolean $deep Whether to also clear the references on all referrer objects.
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:         } // if ($deep)
2222: 
2223:         // i18n behavior
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:      * return the string representation of this object
2247:      *
2248:      * @return string
2249:      */
2250:     public function __toString()
2251:     {
2252:         return (string) $this->exportTo(AttributePeer::DEFAULT_STRING_FORMAT);
2253:     }
2254: 
2255:     /**
2256:      * return true is the object is in saving state
2257:      *
2258:      * @return boolean
2259:      */
2260:     public function isAlreadyInSave()
2261:     {
2262:         return $this->alreadyInSave;
2263:     }
2264: 
2265:     // timestampable behavior
2266: 
2267:     /**
2268:      * Mark the current object so that the update date doesn't get updated during next save
2269:      *
2270:      * @return     Attribute The current object (for fluent API support)
2271:      */
2272:     public function keepUpdateDateUnchanged()
2273:     {
2274:         $this->modifiedColumns[] = AttributePeer::UPDATED_AT;
2275: 
2276:         return $this;
2277:     }
2278: 
2279:     // i18n behavior
2280: 
2281:     /**
2282:      * Sets the locale for translations
2283:      *
2284:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
2285:      *
2286:      * @return    Attribute The current object (for fluent API support)
2287:      */
2288:     public function setLocale($locale = 'en_US')
2289:     {
2290:         $this->currentLocale = $locale;
2291: 
2292:         return $this;
2293:     }
2294: 
2295:     /**
2296:      * Gets the locale for translations
2297:      *
2298:      * @return    string $locale Locale to use for the translation, e.g. 'fr_FR'
2299:      */
2300:     public function getLocale()
2301:     {
2302:         return $this->currentLocale;
2303:     }
2304: 
2305:     /**
2306:      * Returns the current translation for a given locale
2307:      *
2308:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
2309:      * @param     PropelPDO $con an optional connection object
2310:      *
2311:      * @return AttributeI18n */
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:      * Remove the translation for a given locale
2341:      *
2342:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
2343:      * @param     PropelPDO $con an optional connection object
2344:      *
2345:      * @return    Attribute The current object (for fluent API support)
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:      * Returns the current translation
2369:      *
2370:      * @param     PropelPDO $con an optional connection object
2371:      *
2372:      * @return AttributeI18n */
2373:     public function getCurrentTranslation(PropelPDO $con = null)
2374:     {
2375:         return $this->getTranslation($this->getLocale(), $con);
2376:     }
2377: 
2378: 
2379:         /**
2380:          * Get the [title] column value.
2381:          *
2382:          * @return string
2383:          */
2384:         public function getTitle()
2385:         {
2386:         return $this->getCurrentTranslation()->getTitle();
2387:     }
2388: 
2389: 
2390:         /**
2391:          * Set the value of [title] column.
2392:          *
2393:          * @param string $v new value
2394:          * @return AttributeI18n The current object (for fluent API support)
2395:          */
2396:         public function setTitle($v)
2397:         {    $this->getCurrentTranslation()->setTitle($v);
2398: 
2399:         return $this;
2400:     }
2401: 
2402: 
2403:         /**
2404:          * Get the [description] column value.
2405:          *
2406:          * @return string
2407:          */
2408:         public function getDescription()
2409:         {
2410:         return $this->getCurrentTranslation()->getDescription();
2411:     }
2412: 
2413: 
2414:         /**
2415:          * Set the value of [description] column.
2416:          *
2417:          * @param string $v new value
2418:          * @return AttributeI18n The current object (for fluent API support)
2419:          */
2420:         public function setDescription($v)
2421:         {    $this->getCurrentTranslation()->setDescription($v);
2422: 
2423:         return $this;
2424:     }
2425: 
2426: 
2427:         /**
2428:          * Get the [chapo] column value.
2429:          *
2430:          * @return string
2431:          */
2432:         public function getChapo()
2433:         {
2434:         return $this->getCurrentTranslation()->getChapo();
2435:     }
2436: 
2437: 
2438:         /**
2439:          * Set the value of [chapo] column.
2440:          *
2441:          * @param string $v new value
2442:          * @return AttributeI18n The current object (for fluent API support)
2443:          */
2444:         public function setChapo($v)
2445:         {    $this->getCurrentTranslation()->setChapo($v);
2446: 
2447:         return $this;
2448:     }
2449: 
2450: 
2451:         /**
2452:          * Get the [postscriptum] column value.
2453:          *
2454:          * @return string
2455:          */
2456:         public function getPostscriptum()
2457:         {
2458:         return $this->getCurrentTranslation()->getPostscriptum();
2459:     }
2460: 
2461: 
2462:         /**
2463:          * Set the value of [postscriptum] column.
2464:          *
2465:          * @param string $v new value
2466:          * @return AttributeI18n The current object (for fluent API support)
2467:          */
2468:         public function setPostscriptum($v)
2469:         {    $this->getCurrentTranslation()->setPostscriptum($v);
2470: 
2471:         return $this;
2472:     }
2473: 
2474: }
2475: 
thelia API documentation generated by ApiGen 2.8.0