Overview

Namespaces

  • PHP
  • Thelia
    • Action
    • Controller
    • Core
      • Bundle
      • Event
      • EventListener
      • Template
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools

Classes

  • BaseAccessory
  • BaseAccessoryPeer
  • BaseAccessoryQuery
  • BaseAddress
  • BaseAddressPeer
  • BaseAddressQuery
  • BaseAdmin
  • BaseAdminGroup
  • BaseAdminGroupPeer
  • BaseAdminGroupQuery
  • BaseAdminLog
  • BaseAdminLogPeer
  • BaseAdminLogQuery
  • BaseAdminPeer
  • BaseAdminQuery
  • BaseArea
  • BaseAreaPeer
  • BaseAreaQuery
  • BaseAttribute
  • BaseAttributeAv
  • BaseAttributeAvDesc
  • BaseAttributeAvDescPeer
  • BaseAttributeAvDescQuery
  • BaseAttributeAvI18n
  • BaseAttributeAvI18nPeer
  • BaseAttributeAvI18nQuery
  • BaseAttributeAvPeer
  • BaseAttributeAvQuery
  • BaseAttributeCategory
  • BaseAttributeCategoryPeer
  • BaseAttributeCategoryQuery
  • BaseAttributeCombination
  • BaseAttributeCombinationPeer
  • BaseAttributeCombinationQuery
  • BaseAttributeDesc
  • BaseAttributeDescPeer
  • BaseAttributeDescQuery
  • BaseAttributeI18n
  • BaseAttributeI18nPeer
  • BaseAttributeI18nQuery
  • BaseAttributePeer
  • BaseAttributeQuery
  • BaseCategory
  • BaseCategoryDesc
  • BaseCategoryDescPeer
  • BaseCategoryDescQuery
  • BaseCategoryI18n
  • BaseCategoryI18nPeer
  • BaseCategoryI18nQuery
  • BaseCategoryPeer
  • BaseCategoryQuery
  • BaseCategoryVersion
  • BaseCategoryVersionPeer
  • BaseCategoryVersionQuery
  • BaseCombination
  • BaseCombinationPeer
  • BaseCombinationQuery
  • BaseConfig
  • BaseConfigDesc
  • BaseConfigDescPeer
  • BaseConfigDescQuery
  • BaseConfigI18n
  • BaseConfigI18nPeer
  • BaseConfigI18nQuery
  • BaseConfigPeer
  • BaseConfigQuery
  • BaseContent
  • BaseContentAssoc
  • BaseContentAssocPeer
  • BaseContentAssocQuery
  • BaseContentDesc
  • BaseContentDescPeer
  • BaseContentDescQuery
  • BaseContentFolder
  • BaseContentFolderPeer
  • BaseContentFolderQuery
  • BaseContentI18n
  • BaseContentI18nPeer
  • BaseContentI18nQuery
  • BaseContentPeer
  • BaseContentQuery
  • BaseContentVersion
  • BaseContentVersionPeer
  • BaseContentVersionQuery
  • BaseCountry
  • BaseCountryDesc
  • BaseCountryDescPeer
  • BaseCountryDescQuery
  • BaseCountryI18n
  • BaseCountryI18nPeer
  • BaseCountryI18nQuery
  • BaseCountryPeer
  • BaseCountryQuery
  • BaseCoupon
  • BaseCouponOrder
  • BaseCouponOrderPeer
  • BaseCouponOrderQuery
  • BaseCouponPeer
  • BaseCouponQuery
  • BaseCouponRule
  • BaseCouponRulePeer
  • BaseCouponRuleQuery
  • BaseCurrency
  • BaseCurrencyPeer
  • BaseCurrencyQuery
  • BaseCustomer
  • BaseCustomerPeer
  • BaseCustomerQuery
  • BaseCustomerTitle
  • BaseCustomerTitleDesc
  • BaseCustomerTitleDescPeer
  • BaseCustomerTitleDescQuery
  • BaseCustomerTitleI18n
  • BaseCustomerTitleI18nPeer
  • BaseCustomerTitleI18nQuery
  • BaseCustomerTitlePeer
  • BaseCustomerTitleQuery
  • BaseDelivzone
  • BaseDelivzonePeer
  • BaseDelivzoneQuery
  • BaseDocument
  • BaseDocumentDesc
  • BaseDocumentDescPeer
  • BaseDocumentDescQuery
  • BaseDocumentI18n
  • BaseDocumentI18nPeer
  • BaseDocumentI18nQuery
  • BaseDocumentPeer
  • BaseDocumentQuery
  • BaseFeature
  • BaseFeatureAv
  • BaseFeatureAvDesc
  • BaseFeatureAvDescPeer
  • BaseFeatureAvDescQuery
  • BaseFeatureAvI18n
  • BaseFeatureAvI18nPeer
  • BaseFeatureAvI18nQuery
  • BaseFeatureAvPeer
  • BaseFeatureAvQuery
  • BaseFeatureCategory
  • BaseFeatureCategoryPeer
  • BaseFeatureCategoryQuery
  • BaseFeatureDesc
  • BaseFeatureDescPeer
  • BaseFeatureDescQuery
  • BaseFeatureI18n
  • BaseFeatureI18nPeer
  • BaseFeatureI18nQuery
  • BaseFeaturePeer
  • BaseFeatureProd
  • BaseFeatureProdPeer
  • BaseFeatureProdQuery
  • BaseFeatureQuery
  • BaseFolder
  • BaseFolderDesc
  • BaseFolderDescPeer
  • BaseFolderDescQuery
  • BaseFolderI18n
  • BaseFolderI18nPeer
  • BaseFolderI18nQuery
  • BaseFolderPeer
  • BaseFolderQuery
  • BaseFolderVersion
  • BaseFolderVersionPeer
  • BaseFolderVersionQuery
  • BaseGroup
  • BaseGroupDesc
  • BaseGroupDescPeer
  • BaseGroupDescQuery
  • BaseGroupI18n
  • BaseGroupI18nPeer
  • BaseGroupI18nQuery
  • BaseGroupModule
  • BaseGroupModulePeer
  • BaseGroupModuleQuery
  • BaseGroupPeer
  • BaseGroupQuery
  • BaseGroupResource
  • BaseGroupResourcePeer
  • BaseGroupResourceQuery
  • BaseImage
  • BaseImageDesc
  • BaseImageDescPeer
  • BaseImageDescQuery
  • BaseImageI18n
  • BaseImageI18nPeer
  • BaseImageI18nQuery
  • BaseImagePeer
  • BaseImageQuery
  • BaseLang
  • BaseLangPeer
  • BaseLangQuery
  • BaseMessage
  • BaseMessageDesc
  • BaseMessageDescPeer
  • BaseMessageDescQuery
  • BaseMessageI18n
  • BaseMessageI18nPeer
  • BaseMessageI18nQuery
  • BaseMessagePeer
  • BaseMessageQuery
  • BaseMessageVersion
  • BaseMessageVersionPeer
  • BaseMessageVersionQuery
  • BaseModuleDesc
  • BaseModuleDescPeer
  • BaseModuleDescQuery
  • BaseModuleI18n
  • BaseModuleI18nPeer
  • BaseModuleI18nQuery
  • BaseModulePeer
  • BaseOrder
  • BaseOrderAddress
  • BaseOrderAddressPeer
  • BaseOrderAddressQuery
  • BaseOrderFeature
  • BaseOrderFeaturePeer
  • BaseOrderFeatureQuery
  • BaseOrderPeer
  • BaseOrderProduct
  • BaseOrderProductPeer
  • BaseOrderProductQuery
  • BaseOrderQuery
  • BaseOrderStatus
  • BaseOrderStatusDesc
  • BaseOrderStatusDescPeer
  • BaseOrderStatusDescQuery
  • BaseOrderStatusI18n
  • BaseOrderStatusI18nPeer
  • BaseOrderStatusI18nQuery
  • BaseOrderStatusPeer
  • BaseOrderStatusQuery
  • BaseProduct
  • BaseProductCategory
  • BaseProductCategoryPeer
  • BaseProductCategoryQuery
  • BaseProductDesc
  • BaseProductDescPeer
  • BaseProductDescQuery
  • BaseProductI18n
  • BaseProductI18nPeer
  • BaseProductI18nQuery
  • BaseProductPeer
  • BaseProductQuery
  • BaseProductVersion
  • BaseProductVersionPeer
  • BaseProductVersionQuery
  • BaseResource
  • BaseResourceDesc
  • BaseResourceDescPeer
  • BaseResourceDescQuery
  • BaseResourceI18n
  • BaseResourceI18nPeer
  • BaseResourceI18nQuery
  • BaseResourcePeer
  • BaseResourceQuery
  • BaseRewriting
  • BaseRewritingPeer
  • BaseRewritingQuery
  • BaseStock
  • BaseStockPeer
  • BaseStockQuery
  • BaseTax
  • BaseTaxDesc
  • BaseTaxDescPeer
  • BaseTaxDescQuery
  • BaseTaxI18n
  • BaseTaxI18nPeer
  • BaseTaxI18nQuery
  • BaseTaxPeer
  • BaseTaxQuery
  • BaseTaxRule
  • BaseTaxRuleCountry
  • BaseTaxRuleCountryPeer
  • BaseTaxRuleCountryQuery
  • BaseTaxRuleDesc
  • BaseTaxRuleDescPeer
  • BaseTaxRuleDescQuery
  • 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\Message;
  19: use Thelia\Model\MessageI18n;
  20: use Thelia\Model\MessageI18nQuery;
  21: use Thelia\Model\MessagePeer;
  22: use Thelia\Model\MessageQuery;
  23: use Thelia\Model\MessageVersion;
  24: use Thelia\Model\MessageVersionPeer;
  25: use Thelia\Model\MessageVersionQuery;
  26: 
  27: /**
  28:  * Base class that represents a row from the 'message' table.
  29:  *
  30:  *
  31:  *
  32:  * @package    propel.generator.Thelia.Model.om
  33:  */
  34: abstract class BaseMessage extends BaseObject implements Persistent
  35: {
  36:     /**
  37:      * Peer class name
  38:      */
  39:     const PEER = 'Thelia\\Model\\MessagePeer';
  40: 
  41:     /**
  42:      * The Peer class.
  43:      * Instance provides a convenient way of calling static methods on a class
  44:      * that calling code may not be able to identify.
  45:      * @var        MessagePeer
  46:      */
  47:     protected static $peer;
  48: 
  49:     /**
  50:      * The flag var to prevent infinit loop in deep copy
  51:      * @var       boolean
  52:      */
  53:     protected $startCopy = false;
  54: 
  55:     /**
  56:      * The value for the id field.
  57:      * @var        int
  58:      */
  59:     protected $id;
  60: 
  61:     /**
  62:      * The value for the code field.
  63:      * @var        string
  64:      */
  65:     protected $code;
  66: 
  67:     /**
  68:      * The value for the secured field.
  69:      * @var        int
  70:      */
  71:     protected $secured;
  72: 
  73:     /**
  74:      * The value for the ref field.
  75:      * @var        string
  76:      */
  77:     protected $ref;
  78: 
  79:     /**
  80:      * The value for the created_at field.
  81:      * @var        string
  82:      */
  83:     protected $created_at;
  84: 
  85:     /**
  86:      * The value for the updated_at field.
  87:      * @var        string
  88:      */
  89:     protected $updated_at;
  90: 
  91:     /**
  92:      * The value for the version field.
  93:      * Note: this column has a database default value of: 0
  94:      * @var        int
  95:      */
  96:     protected $version;
  97: 
  98:     /**
  99:      * The value for the version_created_at field.
 100:      * @var        string
 101:      */
 102:     protected $version_created_at;
 103: 
 104:     /**
 105:      * The value for the version_created_by field.
 106:      * @var        string
 107:      */
 108:     protected $version_created_by;
 109: 
 110:     /**
 111:      * @var        PropelObjectCollection|MessageI18n[] Collection to store aggregation of MessageI18n objects.
 112:      */
 113:     protected $collMessageI18ns;
 114:     protected $collMessageI18nsPartial;
 115: 
 116:     /**
 117:      * @var        PropelObjectCollection|MessageVersion[] Collection to store aggregation of MessageVersion objects.
 118:      */
 119:     protected $collMessageVersions;
 120:     protected $collMessageVersionsPartial;
 121: 
 122:     /**
 123:      * Flag to prevent endless save loop, if this object is referenced
 124:      * by another object which falls in this transaction.
 125:      * @var        boolean
 126:      */
 127:     protected $alreadyInSave = false;
 128: 
 129:     /**
 130:      * Flag to prevent endless validation loop, if this object is referenced
 131:      * by another object which falls in this transaction.
 132:      * @var        boolean
 133:      */
 134:     protected $alreadyInValidation = false;
 135: 
 136:     // i18n behavior
 137: 
 138:     /**
 139:      * Current locale
 140:      * @var        string
 141:      */
 142:     protected $currentLocale = 'en_EN';
 143: 
 144:     /**
 145:      * Current translation objects
 146:      * @var        array[MessageI18n]
 147:      */
 148:     protected $currentTranslations;
 149: 
 150:     // versionable behavior
 151: 
 152: 
 153:     /**
 154:      * @var bool
 155:      */
 156:     protected $enforceVersion = false;
 157: 
 158:     /**
 159:      * An array of objects scheduled for deletion.
 160:      * @var     PropelObjectCollection
 161:      */
 162:     protected $messageI18nsScheduledForDeletion = null;
 163: 
 164:     /**
 165:      * An array of objects scheduled for deletion.
 166:      * @var     PropelObjectCollection
 167:      */
 168:     protected $messageVersionsScheduledForDeletion = null;
 169: 
 170:     /**
 171:      * Applies default values to this object.
 172:      * This method should be called from the object's constructor (or
 173:      * equivalent initialization method).
 174:      * @see        __construct()
 175:      */
 176:     public function applyDefaultValues()
 177:     {
 178:         $this->version = 0;
 179:     }
 180: 
 181:     /**
 182:      * Initializes internal state of BaseMessage object.
 183:      * @see        applyDefaults()
 184:      */
 185:     public function __construct()
 186:     {
 187:         parent::__construct();
 188:         $this->applyDefaultValues();
 189:     }
 190: 
 191:     /**
 192:      * Get the [id] column value.
 193:      *
 194:      * @return int
 195:      */
 196:     public function getId()
 197:     {
 198:         return $this->id;
 199:     }
 200: 
 201:     /**
 202:      * Get the [code] column value.
 203:      *
 204:      * @return string
 205:      */
 206:     public function getCode()
 207:     {
 208:         return $this->code;
 209:     }
 210: 
 211:     /**
 212:      * Get the [secured] column value.
 213:      *
 214:      * @return int
 215:      */
 216:     public function getSecured()
 217:     {
 218:         return $this->secured;
 219:     }
 220: 
 221:     /**
 222:      * Get the [ref] column value.
 223:      *
 224:      * @return string
 225:      */
 226:     public function getRef()
 227:     {
 228:         return $this->ref;
 229:     }
 230: 
 231:     /**
 232:      * Get the [optionally formatted] temporal [created_at] column value.
 233:      *
 234:      *
 235:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 236:      *               If format is null, then the raw DateTime object will be returned.
 237:      * @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
 238:      * @throws PropelException - if unable to parse/validate the date/time value.
 239:      */
 240:     public function getCreatedAt($format = 'Y-m-d H:i:s')
 241:     {
 242:         if ($this->created_at === null) {
 243:             return null;
 244:         }
 245: 
 246:         if ($this->created_at === '0000-00-00 00:00:00') {
 247:             // while technically this is not a default value of null,
 248:             // this seems to be closest in meaning.
 249:             return null;
 250:         } else {
 251:             try {
 252:                 $dt = new DateTime($this->created_at);
 253:             } catch (Exception $x) {
 254:                 throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
 255:             }
 256:         }
 257: 
 258:         if ($format === null) {
 259:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 260:             return $dt;
 261:         } elseif (strpos($format, '%') !== false) {
 262:             return strftime($format, $dt->format('U'));
 263:         } else {
 264:             return $dt->format($format);
 265:         }
 266:     }
 267: 
 268:     /**
 269:      * Get the [optionally formatted] temporal [updated_at] column value.
 270:      *
 271:      *
 272:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 273:      *               If format is null, then the raw DateTime object will be returned.
 274:      * @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
 275:      * @throws PropelException - if unable to parse/validate the date/time value.
 276:      */
 277:     public function getUpdatedAt($format = 'Y-m-d H:i:s')
 278:     {
 279:         if ($this->updated_at === null) {
 280:             return null;
 281:         }
 282: 
 283:         if ($this->updated_at === '0000-00-00 00:00:00') {
 284:             // while technically this is not a default value of null,
 285:             // this seems to be closest in meaning.
 286:             return null;
 287:         } else {
 288:             try {
 289:                 $dt = new DateTime($this->updated_at);
 290:             } catch (Exception $x) {
 291:                 throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
 292:             }
 293:         }
 294: 
 295:         if ($format === null) {
 296:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 297:             return $dt;
 298:         } elseif (strpos($format, '%') !== false) {
 299:             return strftime($format, $dt->format('U'));
 300:         } else {
 301:             return $dt->format($format);
 302:         }
 303:     }
 304: 
 305:     /**
 306:      * Get the [version] column value.
 307:      *
 308:      * @return int
 309:      */
 310:     public function getVersion()
 311:     {
 312:         return $this->version;
 313:     }
 314: 
 315:     /**
 316:      * Get the [optionally formatted] temporal [version_created_at] column value.
 317:      *
 318:      *
 319:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 320:      *               If format is null, then the raw DateTime object will be returned.
 321:      * @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
 322:      * @throws PropelException - if unable to parse/validate the date/time value.
 323:      */
 324:     public function getVersionCreatedAt($format = 'Y-m-d H:i:s')
 325:     {
 326:         if ($this->version_created_at === null) {
 327:             return null;
 328:         }
 329: 
 330:         if ($this->version_created_at === '0000-00-00 00:00:00') {
 331:             // while technically this is not a default value of null,
 332:             // this seems to be closest in meaning.
 333:             return null;
 334:         } else {
 335:             try {
 336:                 $dt = new DateTime($this->version_created_at);
 337:             } catch (Exception $x) {
 338:                 throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
 339:             }
 340:         }
 341: 
 342:         if ($format === null) {
 343:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 344:             return $dt;
 345:         } elseif (strpos($format, '%') !== false) {
 346:             return strftime($format, $dt->format('U'));
 347:         } else {
 348:             return $dt->format($format);
 349:         }
 350:     }
 351: 
 352:     /**
 353:      * Get the [version_created_by] column value.
 354:      *
 355:      * @return string
 356:      */
 357:     public function getVersionCreatedBy()
 358:     {
 359:         return $this->version_created_by;
 360:     }
 361: 
 362:     /**
 363:      * Set the value of [id] column.
 364:      *
 365:      * @param int $v new value
 366:      * @return Message The current object (for fluent API support)
 367:      */
 368:     public function setId($v)
 369:     {
 370:         if ($v !== null) {
 371:             $v = (int) $v;
 372:         }
 373: 
 374:         if ($this->id !== $v) {
 375:             $this->id = $v;
 376:             $this->modifiedColumns[] = MessagePeer::ID;
 377:         }
 378: 
 379: 
 380:         return $this;
 381:     } // setId()
 382: 
 383:     /**
 384:      * Set the value of [code] column.
 385:      *
 386:      * @param string $v new value
 387:      * @return Message The current object (for fluent API support)
 388:      */
 389:     public function setCode($v)
 390:     {
 391:         if ($v !== null) {
 392:             $v = (string) $v;
 393:         }
 394: 
 395:         if ($this->code !== $v) {
 396:             $this->code = $v;
 397:             $this->modifiedColumns[] = MessagePeer::CODE;
 398:         }
 399: 
 400: 
 401:         return $this;
 402:     } // setCode()
 403: 
 404:     /**
 405:      * Set the value of [secured] column.
 406:      *
 407:      * @param int $v new value
 408:      * @return Message The current object (for fluent API support)
 409:      */
 410:     public function setSecured($v)
 411:     {
 412:         if ($v !== null) {
 413:             $v = (int) $v;
 414:         }
 415: 
 416:         if ($this->secured !== $v) {
 417:             $this->secured = $v;
 418:             $this->modifiedColumns[] = MessagePeer::SECURED;
 419:         }
 420: 
 421: 
 422:         return $this;
 423:     } // setSecured()
 424: 
 425:     /**
 426:      * Set the value of [ref] column.
 427:      *
 428:      * @param string $v new value
 429:      * @return Message The current object (for fluent API support)
 430:      */
 431:     public function setRef($v)
 432:     {
 433:         if ($v !== null) {
 434:             $v = (string) $v;
 435:         }
 436: 
 437:         if ($this->ref !== $v) {
 438:             $this->ref = $v;
 439:             $this->modifiedColumns[] = MessagePeer::REF;
 440:         }
 441: 
 442: 
 443:         return $this;
 444:     } // setRef()
 445: 
 446:     /**
 447:      * Sets the value of [created_at] column to a normalized version of the date/time value specified.
 448:      *
 449:      * @param mixed $v string, integer (timestamp), or DateTime value.
 450:      *               Empty strings are treated as null.
 451:      * @return Message The current object (for fluent API support)
 452:      */
 453:     public function setCreatedAt($v)
 454:     {
 455:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 456:         if ($this->created_at !== null || $dt !== null) {
 457:             $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 458:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 459:             if ($currentDateAsString !== $newDateAsString) {
 460:                 $this->created_at = $newDateAsString;
 461:                 $this->modifiedColumns[] = MessagePeer::CREATED_AT;
 462:             }
 463:         } // if either are not null
 464: 
 465: 
 466:         return $this;
 467:     } // setCreatedAt()
 468: 
 469:     /**
 470:      * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
 471:      *
 472:      * @param mixed $v string, integer (timestamp), or DateTime value.
 473:      *               Empty strings are treated as null.
 474:      * @return Message The current object (for fluent API support)
 475:      */
 476:     public function setUpdatedAt($v)
 477:     {
 478:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 479:         if ($this->updated_at !== null || $dt !== null) {
 480:             $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 481:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 482:             if ($currentDateAsString !== $newDateAsString) {
 483:                 $this->updated_at = $newDateAsString;
 484:                 $this->modifiedColumns[] = MessagePeer::UPDATED_AT;
 485:             }
 486:         } // if either are not null
 487: 
 488: 
 489:         return $this;
 490:     } // setUpdatedAt()
 491: 
 492:     /**
 493:      * Set the value of [version] column.
 494:      *
 495:      * @param int $v new value
 496:      * @return Message The current object (for fluent API support)
 497:      */
 498:     public function setVersion($v)
 499:     {
 500:         if ($v !== null) {
 501:             $v = (int) $v;
 502:         }
 503: 
 504:         if ($this->version !== $v) {
 505:             $this->version = $v;
 506:             $this->modifiedColumns[] = MessagePeer::VERSION;
 507:         }
 508: 
 509: 
 510:         return $this;
 511:     } // setVersion()
 512: 
 513:     /**
 514:      * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
 515:      *
 516:      * @param mixed $v string, integer (timestamp), or DateTime value.
 517:      *               Empty strings are treated as null.
 518:      * @return Message The current object (for fluent API support)
 519:      */
 520:     public function setVersionCreatedAt($v)
 521:     {
 522:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 523:         if ($this->version_created_at !== null || $dt !== null) {
 524:             $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 525:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 526:             if ($currentDateAsString !== $newDateAsString) {
 527:                 $this->version_created_at = $newDateAsString;
 528:                 $this->modifiedColumns[] = MessagePeer::VERSION_CREATED_AT;
 529:             }
 530:         } // if either are not null
 531: 
 532: 
 533:         return $this;
 534:     } // setVersionCreatedAt()
 535: 
 536:     /**
 537:      * Set the value of [version_created_by] column.
 538:      *
 539:      * @param string $v new value
 540:      * @return Message The current object (for fluent API support)
 541:      */
 542:     public function setVersionCreatedBy($v)
 543:     {
 544:         if ($v !== null) {
 545:             $v = (string) $v;
 546:         }
 547: 
 548:         if ($this->version_created_by !== $v) {
 549:             $this->version_created_by = $v;
 550:             $this->modifiedColumns[] = MessagePeer::VERSION_CREATED_BY;
 551:         }
 552: 
 553: 
 554:         return $this;
 555:     } // setVersionCreatedBy()
 556: 
 557:     /**
 558:      * Indicates whether the columns in this object are only set to default values.
 559:      *
 560:      * This method can be used in conjunction with isModified() to indicate whether an object is both
 561:      * modified _and_ has some values set which are non-default.
 562:      *
 563:      * @return boolean Whether the columns in this object are only been set with default values.
 564:      */
 565:     public function hasOnlyDefaultValues()
 566:     {
 567:             if ($this->version !== 0) {
 568:                 return false;
 569:             }
 570: 
 571:         // otherwise, everything was equal, so return true
 572:         return true;
 573:     } // hasOnlyDefaultValues()
 574: 
 575:     /**
 576:      * Hydrates (populates) the object variables with values from the database resultset.
 577:      *
 578:      * An offset (0-based "start column") is specified so that objects can be hydrated
 579:      * with a subset of the columns in the resultset rows.  This is needed, for example,
 580:      * for results of JOIN queries where the resultset row includes columns from two or
 581:      * more tables.
 582:      *
 583:      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
 584:      * @param int $startcol 0-based offset column which indicates which restultset column to start with.
 585:      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
 586:      * @return int             next starting column
 587:      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
 588:      */
 589:     public function hydrate($row, $startcol = 0, $rehydrate = false)
 590:     {
 591:         try {
 592: 
 593:             $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
 594:             $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
 595:             $this->secured = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
 596:             $this->ref = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
 597:             $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
 598:             $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
 599:             $this->version = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
 600:             $this->version_created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
 601:             $this->version_created_by = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
 602:             $this->resetModified();
 603: 
 604:             $this->setNew(false);
 605: 
 606:             if ($rehydrate) {
 607:                 $this->ensureConsistency();
 608:             }
 609: 
 610:             return $startcol + 9; // 9 = MessagePeer::NUM_HYDRATE_COLUMNS.
 611: 
 612:         } catch (Exception $e) {
 613:             throw new PropelException("Error populating Message object", $e);
 614:         }
 615:     }
 616: 
 617:     /**
 618:      * Checks and repairs the internal consistency of the object.
 619:      *
 620:      * This method is executed after an already-instantiated object is re-hydrated
 621:      * from the database.  It exists to check any foreign keys to make sure that
 622:      * the objects related to the current object are correct based on foreign key.
 623:      *
 624:      * You can override this method in the stub class, but you should always invoke
 625:      * the base method from the overridden method (i.e. parent::ensureConsistency()),
 626:      * in case your model changes.
 627:      *
 628:      * @throws PropelException
 629:      */
 630:     public function ensureConsistency()
 631:     {
 632: 
 633:     } // ensureConsistency
 634: 
 635:     /**
 636:      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
 637:      *
 638:      * This will only work if the object has been saved and has a valid primary key set.
 639:      *
 640:      * @param boolean $deep (optional) Whether to also de-associated any related objects.
 641:      * @param PropelPDO $con (optional) The PropelPDO connection to use.
 642:      * @return void
 643:      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
 644:      */
 645:     public function reload($deep = false, PropelPDO $con = null)
 646:     {
 647:         if ($this->isDeleted()) {
 648:             throw new PropelException("Cannot reload a deleted object.");
 649:         }
 650: 
 651:         if ($this->isNew()) {
 652:             throw new PropelException("Cannot reload an unsaved object.");
 653:         }
 654: 
 655:         if ($con === null) {
 656:             $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
 657:         }
 658: 
 659:         // We don't need to alter the object instance pool; we're just modifying this instance
 660:         // already in the pool.
 661: 
 662:         $stmt = MessagePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
 663:         $row = $stmt->fetch(PDO::FETCH_NUM);
 664:         $stmt->closeCursor();
 665:         if (!$row) {
 666:             throw new PropelException('Cannot find matching row in the database to reload object values.');
 667:         }
 668:         $this->hydrate($row, 0, true); // rehydrate
 669: 
 670:         if ($deep) {  // also de-associate any related objects?
 671: 
 672:             $this->collMessageI18ns = null;
 673: 
 674:             $this->collMessageVersions = null;
 675: 
 676:         } // if (deep)
 677:     }
 678: 
 679:     /**
 680:      * Removes this object from datastore and sets delete attribute.
 681:      *
 682:      * @param PropelPDO $con
 683:      * @return void
 684:      * @throws PropelException
 685:      * @throws Exception
 686:      * @see        BaseObject::setDeleted()
 687:      * @see        BaseObject::isDeleted()
 688:      */
 689:     public function delete(PropelPDO $con = null)
 690:     {
 691:         if ($this->isDeleted()) {
 692:             throw new PropelException("This object has already been deleted.");
 693:         }
 694: 
 695:         if ($con === null) {
 696:             $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 697:         }
 698: 
 699:         $con->beginTransaction();
 700:         try {
 701:             $deleteQuery = MessageQuery::create()
 702:                 ->filterByPrimaryKey($this->getPrimaryKey());
 703:             $ret = $this->preDelete($con);
 704:             if ($ret) {
 705:                 $deleteQuery->delete($con);
 706:                 $this->postDelete($con);
 707:                 $con->commit();
 708:                 $this->setDeleted(true);
 709:             } else {
 710:                 $con->commit();
 711:             }
 712:         } catch (Exception $e) {
 713:             $con->rollBack();
 714:             throw $e;
 715:         }
 716:     }
 717: 
 718:     /**
 719:      * Persists this object to the database.
 720:      *
 721:      * If the object is new, it inserts it; otherwise an update is performed.
 722:      * All modified related objects will also be persisted in the doSave()
 723:      * method.  This method wraps all precipitate database operations in a
 724:      * single transaction.
 725:      *
 726:      * @param PropelPDO $con
 727:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 728:      * @throws PropelException
 729:      * @throws Exception
 730:      * @see        doSave()
 731:      */
 732:     public function save(PropelPDO $con = null)
 733:     {
 734:         if ($this->isDeleted()) {
 735:             throw new PropelException("You cannot save an object that has been deleted.");
 736:         }
 737: 
 738:         if ($con === null) {
 739:             $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 740:         }
 741: 
 742:         $con->beginTransaction();
 743:         $isInsert = $this->isNew();
 744:         try {
 745:             $ret = $this->preSave($con);
 746:             // versionable behavior
 747:             if ($this->isVersioningNecessary()) {
 748:                 $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
 749:                 if (!$this->isColumnModified(MessagePeer::VERSION_CREATED_AT)) {
 750:                     $this->setVersionCreatedAt(time());
 751:                 }
 752:                 $createVersion = true; // for postSave hook
 753:             }
 754:             if ($isInsert) {
 755:                 $ret = $ret && $this->preInsert($con);
 756:                 // timestampable behavior
 757:                 if (!$this->isColumnModified(MessagePeer::CREATED_AT)) {
 758:                     $this->setCreatedAt(time());
 759:                 }
 760:                 if (!$this->isColumnModified(MessagePeer::UPDATED_AT)) {
 761:                     $this->setUpdatedAt(time());
 762:                 }
 763:             } else {
 764:                 $ret = $ret && $this->preUpdate($con);
 765:                 // timestampable behavior
 766:                 if ($this->isModified() && !$this->isColumnModified(MessagePeer::UPDATED_AT)) {
 767:                     $this->setUpdatedAt(time());
 768:                 }
 769:             }
 770:             if ($ret) {
 771:                 $affectedRows = $this->doSave($con);
 772:                 if ($isInsert) {
 773:                     $this->postInsert($con);
 774:                 } else {
 775:                     $this->postUpdate($con);
 776:                 }
 777:                 $this->postSave($con);
 778:                 // versionable behavior
 779:                 if (isset($createVersion)) {
 780:                     $this->addVersion($con);
 781:                 }
 782:                 MessagePeer::addInstanceToPool($this);
 783:             } else {
 784:                 $affectedRows = 0;
 785:             }
 786:             $con->commit();
 787: 
 788:             return $affectedRows;
 789:         } catch (Exception $e) {
 790:             $con->rollBack();
 791:             throw $e;
 792:         }
 793:     }
 794: 
 795:     /**
 796:      * Performs the work of inserting or updating the row in the database.
 797:      *
 798:      * If the object is new, it inserts it; otherwise an update is performed.
 799:      * All related objects are also updated in this method.
 800:      *
 801:      * @param PropelPDO $con
 802:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 803:      * @throws PropelException
 804:      * @see        save()
 805:      */
 806:     protected function doSave(PropelPDO $con)
 807:     {
 808:         $affectedRows = 0; // initialize var to track total num of affected rows
 809:         if (!$this->alreadyInSave) {
 810:             $this->alreadyInSave = true;
 811: 
 812:             if ($this->isNew() || $this->isModified()) {
 813:                 // persist changes
 814:                 if ($this->isNew()) {
 815:                     $this->doInsert($con);
 816:                 } else {
 817:                     $this->doUpdate($con);
 818:                 }
 819:                 $affectedRows += 1;
 820:                 $this->resetModified();
 821:             }
 822: 
 823:             if ($this->messageI18nsScheduledForDeletion !== null) {
 824:                 if (!$this->messageI18nsScheduledForDeletion->isEmpty()) {
 825:                     MessageI18nQuery::create()
 826:                         ->filterByPrimaryKeys($this->messageI18nsScheduledForDeletion->getPrimaryKeys(false))
 827:                         ->delete($con);
 828:                     $this->messageI18nsScheduledForDeletion = null;
 829:                 }
 830:             }
 831: 
 832:             if ($this->collMessageI18ns !== null) {
 833:                 foreach ($this->collMessageI18ns as $referrerFK) {
 834:                     if (!$referrerFK->isDeleted()) {
 835:                         $affectedRows += $referrerFK->save($con);
 836:                     }
 837:                 }
 838:             }
 839: 
 840:             if ($this->messageVersionsScheduledForDeletion !== null) {
 841:                 if (!$this->messageVersionsScheduledForDeletion->isEmpty()) {
 842:                     MessageVersionQuery::create()
 843:                         ->filterByPrimaryKeys($this->messageVersionsScheduledForDeletion->getPrimaryKeys(false))
 844:                         ->delete($con);
 845:                     $this->messageVersionsScheduledForDeletion = null;
 846:                 }
 847:             }
 848: 
 849:             if ($this->collMessageVersions !== null) {
 850:                 foreach ($this->collMessageVersions as $referrerFK) {
 851:                     if (!$referrerFK->isDeleted()) {
 852:                         $affectedRows += $referrerFK->save($con);
 853:                     }
 854:                 }
 855:             }
 856: 
 857:             $this->alreadyInSave = false;
 858: 
 859:         }
 860: 
 861:         return $affectedRows;
 862:     } // doSave()
 863: 
 864:     /**
 865:      * Insert the row in the database.
 866:      *
 867:      * @param PropelPDO $con
 868:      *
 869:      * @throws PropelException
 870:      * @see        doSave()
 871:      */
 872:     protected function doInsert(PropelPDO $con)
 873:     {
 874:         $modifiedColumns = array();
 875:         $index = 0;
 876: 
 877:         $this->modifiedColumns[] = MessagePeer::ID;
 878:         if (null !== $this->id) {
 879:             throw new PropelException('Cannot insert a value for auto-increment primary key (' . MessagePeer::ID . ')');
 880:         }
 881: 
 882:          // check the columns in natural order for more readable SQL queries
 883:         if ($this->isColumnModified(MessagePeer::ID)) {
 884:             $modifiedColumns[':p' . $index++]  = '`ID`';
 885:         }
 886:         if ($this->isColumnModified(MessagePeer::CODE)) {
 887:             $modifiedColumns[':p' . $index++]  = '`CODE`';
 888:         }
 889:         if ($this->isColumnModified(MessagePeer::SECURED)) {
 890:             $modifiedColumns[':p' . $index++]  = '`SECURED`';
 891:         }
 892:         if ($this->isColumnModified(MessagePeer::REF)) {
 893:             $modifiedColumns[':p' . $index++]  = '`REF`';
 894:         }
 895:         if ($this->isColumnModified(MessagePeer::CREATED_AT)) {
 896:             $modifiedColumns[':p' . $index++]  = '`CREATED_AT`';
 897:         }
 898:         if ($this->isColumnModified(MessagePeer::UPDATED_AT)) {
 899:             $modifiedColumns[':p' . $index++]  = '`UPDATED_AT`';
 900:         }
 901:         if ($this->isColumnModified(MessagePeer::VERSION)) {
 902:             $modifiedColumns[':p' . $index++]  = '`VERSION`';
 903:         }
 904:         if ($this->isColumnModified(MessagePeer::VERSION_CREATED_AT)) {
 905:             $modifiedColumns[':p' . $index++]  = '`VERSION_CREATED_AT`';
 906:         }
 907:         if ($this->isColumnModified(MessagePeer::VERSION_CREATED_BY)) {
 908:             $modifiedColumns[':p' . $index++]  = '`VERSION_CREATED_BY`';
 909:         }
 910: 
 911:         $sql = sprintf(
 912:             'INSERT INTO `message` (%s) VALUES (%s)',
 913:             implode(', ', $modifiedColumns),
 914:             implode(', ', array_keys($modifiedColumns))
 915:         );
 916: 
 917:         try {
 918:             $stmt = $con->prepare($sql);
 919:             foreach ($modifiedColumns as $identifier => $columnName) {
 920:                 switch ($columnName) {
 921:                     case '`ID`':
 922:                         $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
 923:                         break;
 924:                     case '`CODE`':
 925:                         $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
 926:                         break;
 927:                     case '`SECURED`':
 928:                         $stmt->bindValue($identifier, $this->secured, PDO::PARAM_INT);
 929:                         break;
 930:                     case '`REF`':
 931:                         $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
 932:                         break;
 933:                     case '`CREATED_AT`':
 934:                         $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
 935:                         break;
 936:                     case '`UPDATED_AT`':
 937:                         $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
 938:                         break;
 939:                     case '`VERSION`':
 940:                         $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
 941:                         break;
 942:                     case '`VERSION_CREATED_AT`':
 943:                         $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
 944:                         break;
 945:                     case '`VERSION_CREATED_BY`':
 946:                         $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
 947:                         break;
 948:                 }
 949:             }
 950:             $stmt->execute();
 951:         } catch (Exception $e) {
 952:             Propel::log($e->getMessage(), Propel::LOG_ERR);
 953:             throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
 954:         }
 955: 
 956:         try {
 957:             $pk = $con->lastInsertId();
 958:         } catch (Exception $e) {
 959:             throw new PropelException('Unable to get autoincrement id.', $e);
 960:         }
 961:         $this->setId($pk);
 962: 
 963:         $this->setNew(false);
 964:     }
 965: 
 966:     /**
 967:      * Update the row in the database.
 968:      *
 969:      * @param PropelPDO $con
 970:      *
 971:      * @see        doSave()
 972:      */
 973:     protected function doUpdate(PropelPDO $con)
 974:     {
 975:         $selectCriteria = $this->buildPkeyCriteria();
 976:         $valuesCriteria = $this->buildCriteria();
 977:         BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
 978:     }
 979: 
 980:     /**
 981:      * Array of ValidationFailed objects.
 982:      * @var        array ValidationFailed[]
 983:      */
 984:     protected $validationFailures = array();
 985: 
 986:     /**
 987:      * Gets any ValidationFailed objects that resulted from last call to validate().
 988:      *
 989:      *
 990:      * @return array ValidationFailed[]
 991:      * @see        validate()
 992:      */
 993:     public function getValidationFailures()
 994:     {
 995:         return $this->validationFailures;
 996:     }
 997: 
 998:     /**
 999:      * Validates the objects modified field values and all objects related to this table.
1000:      *
1001:      * If $columns is either a column name or an array of column names
1002:      * only those columns are validated.
1003:      *
1004:      * @param mixed $columns Column name or an array of column names.
1005:      * @return boolean Whether all columns pass validation.
1006:      * @see        doValidate()
1007:      * @see        getValidationFailures()
1008:      */
1009:     public function validate($columns = null)
1010:     {
1011:         $res = $this->doValidate($columns);
1012:         if ($res === true) {
1013:             $this->validationFailures = array();
1014: 
1015:             return true;
1016:         } else {
1017:             $this->validationFailures = $res;
1018: 
1019:             return false;
1020:         }
1021:     }
1022: 
1023:     /**
1024:      * This function performs the validation work for complex object models.
1025:      *
1026:      * In addition to checking the current object, all related objects will
1027:      * also be validated.  If all pass then <code>true</code> is returned; otherwise
1028:      * an aggreagated array of ValidationFailed objects will be returned.
1029:      *
1030:      * @param array $columns Array of column names to validate.
1031:      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
1032:      */
1033:     protected function doValidate($columns = null)
1034:     {
1035:         if (!$this->alreadyInValidation) {
1036:             $this->alreadyInValidation = true;
1037:             $retval = null;
1038: 
1039:             $failureMap = array();
1040: 
1041: 
1042:             if (($retval = MessagePeer::doValidate($this, $columns)) !== true) {
1043:                 $failureMap = array_merge($failureMap, $retval);
1044:             }
1045: 
1046: 
1047:                 if ($this->collMessageI18ns !== null) {
1048:                     foreach ($this->collMessageI18ns as $referrerFK) {
1049:                         if (!$referrerFK->validate($columns)) {
1050:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1051:                         }
1052:                     }
1053:                 }
1054: 
1055:                 if ($this->collMessageVersions !== null) {
1056:                     foreach ($this->collMessageVersions as $referrerFK) {
1057:                         if (!$referrerFK->validate($columns)) {
1058:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1059:                         }
1060:                     }
1061:                 }
1062: 
1063: 
1064:             $this->alreadyInValidation = false;
1065:         }
1066: 
1067:         return (!empty($failureMap) ? $failureMap : true);
1068:     }
1069: 
1070:     /**
1071:      * Retrieves a field from the object by name passed in as a string.
1072:      *
1073:      * @param string $name name
1074:      * @param string $type The type of fieldname the $name is of:
1075:      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
1076:      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1077:      *               Defaults to BasePeer::TYPE_PHPNAME
1078:      * @return mixed Value of field.
1079:      */
1080:     public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
1081:     {
1082:         $pos = MessagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1083:         $field = $this->getByPosition($pos);
1084: 
1085:         return $field;
1086:     }
1087: 
1088:     /**
1089:      * Retrieves a field from the object by Position as specified in the xml schema.
1090:      * Zero-based.
1091:      *
1092:      * @param int $pos position in xml schema
1093:      * @return mixed Value of field at $pos
1094:      */
1095:     public function getByPosition($pos)
1096:     {
1097:         switch ($pos) {
1098:             case 0:
1099:                 return $this->getId();
1100:                 break;
1101:             case 1:
1102:                 return $this->getCode();
1103:                 break;
1104:             case 2:
1105:                 return $this->getSecured();
1106:                 break;
1107:             case 3:
1108:                 return $this->getRef();
1109:                 break;
1110:             case 4:
1111:                 return $this->getCreatedAt();
1112:                 break;
1113:             case 5:
1114:                 return $this->getUpdatedAt();
1115:                 break;
1116:             case 6:
1117:                 return $this->getVersion();
1118:                 break;
1119:             case 7:
1120:                 return $this->getVersionCreatedAt();
1121:                 break;
1122:             case 8:
1123:                 return $this->getVersionCreatedBy();
1124:                 break;
1125:             default:
1126:                 return null;
1127:                 break;
1128:         } // switch()
1129:     }
1130: 
1131:     /**
1132:      * Exports the object as an array.
1133:      *
1134:      * You can specify the key type of the array by passing one of the class
1135:      * type constants.
1136:      *
1137:      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1138:      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1139:      *                    Defaults to BasePeer::TYPE_PHPNAME.
1140:      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
1141:      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
1142:      * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
1143:      *
1144:      * @return array an associative array containing the field names (as keys) and field values
1145:      */
1146:     public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
1147:     {
1148:         if (isset($alreadyDumpedObjects['Message'][$this->getPrimaryKey()])) {
1149:             return '*RECURSION*';
1150:         }
1151:         $alreadyDumpedObjects['Message'][$this->getPrimaryKey()] = true;
1152:         $keys = MessagePeer::getFieldNames($keyType);
1153:         $result = array(
1154:             $keys[0] => $this->getId(),
1155:             $keys[1] => $this->getCode(),
1156:             $keys[2] => $this->getSecured(),
1157:             $keys[3] => $this->getRef(),
1158:             $keys[4] => $this->getCreatedAt(),
1159:             $keys[5] => $this->getUpdatedAt(),
1160:             $keys[6] => $this->getVersion(),
1161:             $keys[7] => $this->getVersionCreatedAt(),
1162:             $keys[8] => $this->getVersionCreatedBy(),
1163:         );
1164:         if ($includeForeignObjects) {
1165:             if (null !== $this->collMessageI18ns) {
1166:                 $result['MessageI18ns'] = $this->collMessageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1167:             }
1168:             if (null !== $this->collMessageVersions) {
1169:                 $result['MessageVersions'] = $this->collMessageVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1170:             }
1171:         }
1172: 
1173:         return $result;
1174:     }
1175: 
1176:     /**
1177:      * Sets a field from the object by name passed in as a string.
1178:      *
1179:      * @param string $name peer name
1180:      * @param mixed $value field value
1181:      * @param string $type The type of fieldname the $name is of:
1182:      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
1183:      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1184:      *                     Defaults to BasePeer::TYPE_PHPNAME
1185:      * @return void
1186:      */
1187:     public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
1188:     {
1189:         $pos = MessagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1190: 
1191:         $this->setByPosition($pos, $value);
1192:     }
1193: 
1194:     /**
1195:      * Sets a field from the object by Position as specified in the xml schema.
1196:      * Zero-based.
1197:      *
1198:      * @param int $pos position in xml schema
1199:      * @param mixed $value field value
1200:      * @return void
1201:      */
1202:     public function setByPosition($pos, $value)
1203:     {
1204:         switch ($pos) {
1205:             case 0:
1206:                 $this->setId($value);
1207:                 break;
1208:             case 1:
1209:                 $this->setCode($value);
1210:                 break;
1211:             case 2:
1212:                 $this->setSecured($value);
1213:                 break;
1214:             case 3:
1215:                 $this->setRef($value);
1216:                 break;
1217:             case 4:
1218:                 $this->setCreatedAt($value);
1219:                 break;
1220:             case 5:
1221:                 $this->setUpdatedAt($value);
1222:                 break;
1223:             case 6:
1224:                 $this->setVersion($value);
1225:                 break;
1226:             case 7:
1227:                 $this->setVersionCreatedAt($value);
1228:                 break;
1229:             case 8:
1230:                 $this->setVersionCreatedBy($value);
1231:                 break;
1232:         } // switch()
1233:     }
1234: 
1235:     /**
1236:      * Populates the object using an array.
1237:      *
1238:      * This is particularly useful when populating an object from one of the
1239:      * request arrays (e.g. $_POST).  This method goes through the column
1240:      * names, checking to see whether a matching key exists in populated
1241:      * array. If so the setByName() method is called for that column.
1242:      *
1243:      * You can specify the key type of the array by additionally passing one
1244:      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1245:      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1246:      * The default key type is the column's BasePeer::TYPE_PHPNAME
1247:      *
1248:      * @param array  $arr     An array to populate the object from.
1249:      * @param string $keyType The type of keys the array uses.
1250:      * @return void
1251:      */
1252:     public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
1253:     {
1254:         $keys = MessagePeer::getFieldNames($keyType);
1255: 
1256:         if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
1257:         if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
1258:         if (array_key_exists($keys[2], $arr)) $this->setSecured($arr[$keys[2]]);
1259:         if (array_key_exists($keys[3], $arr)) $this->setRef($arr[$keys[3]]);
1260:         if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
1261:         if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
1262:         if (array_key_exists($keys[6], $arr)) $this->setVersion($arr[$keys[6]]);
1263:         if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedAt($arr[$keys[7]]);
1264:         if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedBy($arr[$keys[8]]);
1265:     }
1266: 
1267:     /**
1268:      * Build a Criteria object containing the values of all modified columns in this object.
1269:      *
1270:      * @return Criteria The Criteria object containing all modified values.
1271:      */
1272:     public function buildCriteria()
1273:     {
1274:         $criteria = new Criteria(MessagePeer::DATABASE_NAME);
1275: 
1276:         if ($this->isColumnModified(MessagePeer::ID)) $criteria->add(MessagePeer::ID, $this->id);
1277:         if ($this->isColumnModified(MessagePeer::CODE)) $criteria->add(MessagePeer::CODE, $this->code);
1278:         if ($this->isColumnModified(MessagePeer::SECURED)) $criteria->add(MessagePeer::SECURED, $this->secured);
1279:         if ($this->isColumnModified(MessagePeer::REF)) $criteria->add(MessagePeer::REF, $this->ref);
1280:         if ($this->isColumnModified(MessagePeer::CREATED_AT)) $criteria->add(MessagePeer::CREATED_AT, $this->created_at);
1281:         if ($this->isColumnModified(MessagePeer::UPDATED_AT)) $criteria->add(MessagePeer::UPDATED_AT, $this->updated_at);
1282:         if ($this->isColumnModified(MessagePeer::VERSION)) $criteria->add(MessagePeer::VERSION, $this->version);
1283:         if ($this->isColumnModified(MessagePeer::VERSION_CREATED_AT)) $criteria->add(MessagePeer::VERSION_CREATED_AT, $this->version_created_at);
1284:         if ($this->isColumnModified(MessagePeer::VERSION_CREATED_BY)) $criteria->add(MessagePeer::VERSION_CREATED_BY, $this->version_created_by);
1285: 
1286:         return $criteria;
1287:     }
1288: 
1289:     /**
1290:      * Builds a Criteria object containing the primary key for this object.
1291:      *
1292:      * Unlike buildCriteria() this method includes the primary key values regardless
1293:      * of whether or not they have been modified.
1294:      *
1295:      * @return Criteria The Criteria object containing value(s) for primary key(s).
1296:      */
1297:     public function buildPkeyCriteria()
1298:     {
1299:         $criteria = new Criteria(MessagePeer::DATABASE_NAME);
1300:         $criteria->add(MessagePeer::ID, $this->id);
1301: 
1302:         return $criteria;
1303:     }
1304: 
1305:     /**
1306:      * Returns the primary key for this object (row).
1307:      * @return int
1308:      */
1309:     public function getPrimaryKey()
1310:     {
1311:         return $this->getId();
1312:     }
1313: 
1314:     /**
1315:      * Generic method to set the primary key (id column).
1316:      *
1317:      * @param  int $key Primary key.
1318:      * @return void
1319:      */
1320:     public function setPrimaryKey($key)
1321:     {
1322:         $this->setId($key);
1323:     }
1324: 
1325:     /**
1326:      * Returns true if the primary key for this object is null.
1327:      * @return boolean
1328:      */
1329:     public function isPrimaryKeyNull()
1330:     {
1331: 
1332:         return null === $this->getId();
1333:     }
1334: 
1335:     /**
1336:      * Sets contents of passed object to values from current object.
1337:      *
1338:      * If desired, this method can also make copies of all associated (fkey referrers)
1339:      * objects.
1340:      *
1341:      * @param object $copyObj An object of Message (or compatible) type.
1342:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1343:      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1344:      * @throws PropelException
1345:      */
1346:     public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1347:     {
1348:         $copyObj->setCode($this->getCode());
1349:         $copyObj->setSecured($this->getSecured());
1350:         $copyObj->setRef($this->getRef());
1351:         $copyObj->setCreatedAt($this->getCreatedAt());
1352:         $copyObj->setUpdatedAt($this->getUpdatedAt());
1353:         $copyObj->setVersion($this->getVersion());
1354:         $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
1355:         $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
1356: 
1357:         if ($deepCopy && !$this->startCopy) {
1358:             // important: temporarily setNew(false) because this affects the behavior of
1359:             // the getter/setter methods for fkey referrer objects.
1360:             $copyObj->setNew(false);
1361:             // store object hash to prevent cycle
1362:             $this->startCopy = true;
1363: 
1364:             foreach ($this->getMessageI18ns() as $relObj) {
1365:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1366:                     $copyObj->addMessageI18n($relObj->copy($deepCopy));
1367:                 }
1368:             }
1369: 
1370:             foreach ($this->getMessageVersions() as $relObj) {
1371:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1372:                     $copyObj->addMessageVersion($relObj->copy($deepCopy));
1373:                 }
1374:             }
1375: 
1376:             //unflag object copy
1377:             $this->startCopy = false;
1378:         } // if ($deepCopy)
1379: 
1380:         if ($makeNew) {
1381:             $copyObj->setNew(true);
1382:             $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
1383:         }
1384:     }
1385: 
1386:     /**
1387:      * Makes a copy of this object that will be inserted as a new row in table when saved.
1388:      * It creates a new object filling in the simple attributes, but skipping any primary
1389:      * keys that are defined for the table.
1390:      *
1391:      * If desired, this method can also make copies of all associated (fkey referrers)
1392:      * objects.
1393:      *
1394:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1395:      * @return Message Clone of current object.
1396:      * @throws PropelException
1397:      */
1398:     public function copy($deepCopy = false)
1399:     {
1400:         // we use get_class(), because this might be a subclass
1401:         $clazz = get_class($this);
1402:         $copyObj = new $clazz();
1403:         $this->copyInto($copyObj, $deepCopy);
1404: 
1405:         return $copyObj;
1406:     }
1407: 
1408:     /**
1409:      * Returns a peer instance associated with this om.
1410:      *
1411:      * Since Peer classes are not to have any instance attributes, this method returns the
1412:      * same instance for all member of this class. The method could therefore
1413:      * be static, but this would prevent one from overriding the behavior.
1414:      *
1415:      * @return MessagePeer
1416:      */
1417:     public function getPeer()
1418:     {
1419:         if (self::$peer === null) {
1420:             self::$peer = new MessagePeer();
1421:         }
1422: 
1423:         return self::$peer;
1424:     }
1425: 
1426: 
1427:     /**
1428:      * Initializes a collection based on the name of a relation.
1429:      * Avoids crafting an 'init[$relationName]s' method name
1430:      * that wouldn't work when StandardEnglishPluralizer is used.
1431:      *
1432:      * @param string $relationName The name of the relation to initialize
1433:      * @return void
1434:      */
1435:     public function initRelation($relationName)
1436:     {
1437:         if ('MessageI18n' == $relationName) {
1438:             $this->initMessageI18ns();
1439:         }
1440:         if ('MessageVersion' == $relationName) {
1441:             $this->initMessageVersions();
1442:         }
1443:     }
1444: 
1445:     /**
1446:      * Clears out the collMessageI18ns collection
1447:      *
1448:      * This does not modify the database; however, it will remove any associated objects, causing
1449:      * them to be refetched by subsequent calls to accessor method.
1450:      *
1451:      * @return void
1452:      * @see        addMessageI18ns()
1453:      */
1454:     public function clearMessageI18ns()
1455:     {
1456:         $this->collMessageI18ns = null; // important to set this to null since that means it is uninitialized
1457:         $this->collMessageI18nsPartial = null;
1458:     }
1459: 
1460:     /**
1461:      * reset is the collMessageI18ns collection loaded partially
1462:      *
1463:      * @return void
1464:      */
1465:     public function resetPartialMessageI18ns($v = true)
1466:     {
1467:         $this->collMessageI18nsPartial = $v;
1468:     }
1469: 
1470:     /**
1471:      * Initializes the collMessageI18ns collection.
1472:      *
1473:      * By default this just sets the collMessageI18ns collection to an empty array (like clearcollMessageI18ns());
1474:      * however, you may wish to override this method in your stub class to provide setting appropriate
1475:      * to your application -- for example, setting the initial array to the values stored in database.
1476:      *
1477:      * @param boolean $overrideExisting If set to true, the method call initializes
1478:      *                                        the collection even if it is not empty
1479:      *
1480:      * @return void
1481:      */
1482:     public function initMessageI18ns($overrideExisting = true)
1483:     {
1484:         if (null !== $this->collMessageI18ns && !$overrideExisting) {
1485:             return;
1486:         }
1487:         $this->collMessageI18ns = new PropelObjectCollection();
1488:         $this->collMessageI18ns->setModel('MessageI18n');
1489:     }
1490: 
1491:     /**
1492:      * Gets an array of MessageI18n objects which contain a foreign key that references this object.
1493:      *
1494:      * If the $criteria is not null, it is used to always fetch the results from the database.
1495:      * Otherwise the results are fetched from the database the first time, then cached.
1496:      * Next time the same method is called without $criteria, the cached collection is returned.
1497:      * If this Message is new, it will return
1498:      * an empty collection or the current collection; the criteria is ignored on a new object.
1499:      *
1500:      * @param Criteria $criteria optional Criteria object to narrow the query
1501:      * @param PropelPDO $con optional connection object
1502:      * @return PropelObjectCollection|MessageI18n[] List of MessageI18n objects
1503:      * @throws PropelException
1504:      */
1505:     public function getMessageI18ns($criteria = null, PropelPDO $con = null)
1506:     {
1507:         $partial = $this->collMessageI18nsPartial && !$this->isNew();
1508:         if (null === $this->collMessageI18ns || null !== $criteria  || $partial) {
1509:             if ($this->isNew() && null === $this->collMessageI18ns) {
1510:                 // return empty collection
1511:                 $this->initMessageI18ns();
1512:             } else {
1513:                 $collMessageI18ns = MessageI18nQuery::create(null, $criteria)
1514:                     ->filterByMessage($this)
1515:                     ->find($con);
1516:                 if (null !== $criteria) {
1517:                     if (false !== $this->collMessageI18nsPartial && count($collMessageI18ns)) {
1518:                       $this->initMessageI18ns(false);
1519: 
1520:                       foreach($collMessageI18ns as $obj) {
1521:                         if (false == $this->collMessageI18ns->contains($obj)) {
1522:                           $this->collMessageI18ns->append($obj);
1523:                         }
1524:                       }
1525: 
1526:                       $this->collMessageI18nsPartial = true;
1527:                     }
1528: 
1529:                     return $collMessageI18ns;
1530:                 }
1531: 
1532:                 if($partial && $this->collMessageI18ns) {
1533:                     foreach($this->collMessageI18ns as $obj) {
1534:                         if($obj->isNew()) {
1535:                             $collMessageI18ns[] = $obj;
1536:                         }
1537:                     }
1538:                 }
1539: 
1540:                 $this->collMessageI18ns = $collMessageI18ns;
1541:                 $this->collMessageI18nsPartial = false;
1542:             }
1543:         }
1544: 
1545:         return $this->collMessageI18ns;
1546:     }
1547: 
1548:     /**
1549:      * Sets a collection of MessageI18n objects related by a one-to-many relationship
1550:      * to the current object.
1551:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1552:      * and new objects from the given Propel collection.
1553:      *
1554:      * @param PropelCollection $messageI18ns A Propel collection.
1555:      * @param PropelPDO $con Optional connection object
1556:      */
1557:     public function setMessageI18ns(PropelCollection $messageI18ns, PropelPDO $con = null)
1558:     {
1559:         $this->messageI18nsScheduledForDeletion = $this->getMessageI18ns(new Criteria(), $con)->diff($messageI18ns);
1560: 
1561:         foreach ($this->messageI18nsScheduledForDeletion as $messageI18nRemoved) {
1562:             $messageI18nRemoved->setMessage(null);
1563:         }
1564: 
1565:         $this->collMessageI18ns = null;
1566:         foreach ($messageI18ns as $messageI18n) {
1567:             $this->addMessageI18n($messageI18n);
1568:         }
1569: 
1570:         $this->collMessageI18ns = $messageI18ns;
1571:         $this->collMessageI18nsPartial = false;
1572:     }
1573: 
1574:     /**
1575:      * Returns the number of related MessageI18n objects.
1576:      *
1577:      * @param Criteria $criteria
1578:      * @param boolean $distinct
1579:      * @param PropelPDO $con
1580:      * @return int             Count of related MessageI18n objects.
1581:      * @throws PropelException
1582:      */
1583:     public function countMessageI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1584:     {
1585:         $partial = $this->collMessageI18nsPartial && !$this->isNew();
1586:         if (null === $this->collMessageI18ns || null !== $criteria || $partial) {
1587:             if ($this->isNew() && null === $this->collMessageI18ns) {
1588:                 return 0;
1589:             } else {
1590:                 if($partial && !$criteria) {
1591:                     return count($this->getMessageI18ns());
1592:                 }
1593:                 $query = MessageI18nQuery::create(null, $criteria);
1594:                 if ($distinct) {
1595:                     $query->distinct();
1596:                 }
1597: 
1598:                 return $query
1599:                     ->filterByMessage($this)
1600:                     ->count($con);
1601:             }
1602:         } else {
1603:             return count($this->collMessageI18ns);
1604:         }
1605:     }
1606: 
1607:     /**
1608:      * Method called to associate a MessageI18n object to this object
1609:      * through the MessageI18n foreign key attribute.
1610:      *
1611:      * @param    MessageI18n $l MessageI18n
1612:      * @return Message The current object (for fluent API support)
1613:      */
1614:     public function addMessageI18n(MessageI18n $l)
1615:     {
1616:         if ($l && $locale = $l->getLocale()) {
1617:             $this->setLocale($locale);
1618:             $this->currentTranslations[$locale] = $l;
1619:         }
1620:         if ($this->collMessageI18ns === null) {
1621:             $this->initMessageI18ns();
1622:             $this->collMessageI18nsPartial = true;
1623:         }
1624:         if (!$this->collMessageI18ns->contains($l)) { // only add it if the **same** object is not already associated
1625:             $this->doAddMessageI18n($l);
1626:         }
1627: 
1628:         return $this;
1629:     }
1630: 
1631:     /**
1632:      * @param   MessageI18n $messageI18n The messageI18n object to add.
1633:      */
1634:     protected function doAddMessageI18n($messageI18n)
1635:     {
1636:         $this->collMessageI18ns[]= $messageI18n;
1637:         $messageI18n->setMessage($this);
1638:     }
1639: 
1640:     /**
1641:      * @param   MessageI18n $messageI18n The messageI18n object to remove.
1642:      */
1643:     public function removeMessageI18n($messageI18n)
1644:     {
1645:         if ($this->getMessageI18ns()->contains($messageI18n)) {
1646:             $this->collMessageI18ns->remove($this->collMessageI18ns->search($messageI18n));
1647:             if (null === $this->messageI18nsScheduledForDeletion) {
1648:                 $this->messageI18nsScheduledForDeletion = clone $this->collMessageI18ns;
1649:                 $this->messageI18nsScheduledForDeletion->clear();
1650:             }
1651:             $this->messageI18nsScheduledForDeletion[]= $messageI18n;
1652:             $messageI18n->setMessage(null);
1653:         }
1654:     }
1655: 
1656:     /**
1657:      * Clears out the collMessageVersions collection
1658:      *
1659:      * This does not modify the database; however, it will remove any associated objects, causing
1660:      * them to be refetched by subsequent calls to accessor method.
1661:      *
1662:      * @return void
1663:      * @see        addMessageVersions()
1664:      */
1665:     public function clearMessageVersions()
1666:     {
1667:         $this->collMessageVersions = null; // important to set this to null since that means it is uninitialized
1668:         $this->collMessageVersionsPartial = null;
1669:     }
1670: 
1671:     /**
1672:      * reset is the collMessageVersions collection loaded partially
1673:      *
1674:      * @return void
1675:      */
1676:     public function resetPartialMessageVersions($v = true)
1677:     {
1678:         $this->collMessageVersionsPartial = $v;
1679:     }
1680: 
1681:     /**
1682:      * Initializes the collMessageVersions collection.
1683:      *
1684:      * By default this just sets the collMessageVersions collection to an empty array (like clearcollMessageVersions());
1685:      * however, you may wish to override this method in your stub class to provide setting appropriate
1686:      * to your application -- for example, setting the initial array to the values stored in database.
1687:      *
1688:      * @param boolean $overrideExisting If set to true, the method call initializes
1689:      *                                        the collection even if it is not empty
1690:      *
1691:      * @return void
1692:      */
1693:     public function initMessageVersions($overrideExisting = true)
1694:     {
1695:         if (null !== $this->collMessageVersions && !$overrideExisting) {
1696:             return;
1697:         }
1698:         $this->collMessageVersions = new PropelObjectCollection();
1699:         $this->collMessageVersions->setModel('MessageVersion');
1700:     }
1701: 
1702:     /**
1703:      * Gets an array of MessageVersion objects which contain a foreign key that references this object.
1704:      *
1705:      * If the $criteria is not null, it is used to always fetch the results from the database.
1706:      * Otherwise the results are fetched from the database the first time, then cached.
1707:      * Next time the same method is called without $criteria, the cached collection is returned.
1708:      * If this Message is new, it will return
1709:      * an empty collection or the current collection; the criteria is ignored on a new object.
1710:      *
1711:      * @param Criteria $criteria optional Criteria object to narrow the query
1712:      * @param PropelPDO $con optional connection object
1713:      * @return PropelObjectCollection|MessageVersion[] List of MessageVersion objects
1714:      * @throws PropelException
1715:      */
1716:     public function getMessageVersions($criteria = null, PropelPDO $con = null)
1717:     {
1718:         $partial = $this->collMessageVersionsPartial && !$this->isNew();
1719:         if (null === $this->collMessageVersions || null !== $criteria  || $partial) {
1720:             if ($this->isNew() && null === $this->collMessageVersions) {
1721:                 // return empty collection
1722:                 $this->initMessageVersions();
1723:             } else {
1724:                 $collMessageVersions = MessageVersionQuery::create(null, $criteria)
1725:                     ->filterByMessage($this)
1726:                     ->find($con);
1727:                 if (null !== $criteria) {
1728:                     if (false !== $this->collMessageVersionsPartial && count($collMessageVersions)) {
1729:                       $this->initMessageVersions(false);
1730: 
1731:                       foreach($collMessageVersions as $obj) {
1732:                         if (false == $this->collMessageVersions->contains($obj)) {
1733:                           $this->collMessageVersions->append($obj);
1734:                         }
1735:                       }
1736: 
1737:                       $this->collMessageVersionsPartial = true;
1738:                     }
1739: 
1740:                     return $collMessageVersions;
1741:                 }
1742: 
1743:                 if($partial && $this->collMessageVersions) {
1744:                     foreach($this->collMessageVersions as $obj) {
1745:                         if($obj->isNew()) {
1746:                             $collMessageVersions[] = $obj;
1747:                         }
1748:                     }
1749:                 }
1750: 
1751:                 $this->collMessageVersions = $collMessageVersions;
1752:                 $this->collMessageVersionsPartial = false;
1753:             }
1754:         }
1755: 
1756:         return $this->collMessageVersions;
1757:     }
1758: 
1759:     /**
1760:      * Sets a collection of MessageVersion objects related by a one-to-many relationship
1761:      * to the current object.
1762:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1763:      * and new objects from the given Propel collection.
1764:      *
1765:      * @param PropelCollection $messageVersions A Propel collection.
1766:      * @param PropelPDO $con Optional connection object
1767:      */
1768:     public function setMessageVersions(PropelCollection $messageVersions, PropelPDO $con = null)
1769:     {
1770:         $this->messageVersionsScheduledForDeletion = $this->getMessageVersions(new Criteria(), $con)->diff($messageVersions);
1771: 
1772:         foreach ($this->messageVersionsScheduledForDeletion as $messageVersionRemoved) {
1773:             $messageVersionRemoved->setMessage(null);
1774:         }
1775: 
1776:         $this->collMessageVersions = null;
1777:         foreach ($messageVersions as $messageVersion) {
1778:             $this->addMessageVersion($messageVersion);
1779:         }
1780: 
1781:         $this->collMessageVersions = $messageVersions;
1782:         $this->collMessageVersionsPartial = false;
1783:     }
1784: 
1785:     /**
1786:      * Returns the number of related MessageVersion objects.
1787:      *
1788:      * @param Criteria $criteria
1789:      * @param boolean $distinct
1790:      * @param PropelPDO $con
1791:      * @return int             Count of related MessageVersion objects.
1792:      * @throws PropelException
1793:      */
1794:     public function countMessageVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1795:     {
1796:         $partial = $this->collMessageVersionsPartial && !$this->isNew();
1797:         if (null === $this->collMessageVersions || null !== $criteria || $partial) {
1798:             if ($this->isNew() && null === $this->collMessageVersions) {
1799:                 return 0;
1800:             } else {
1801:                 if($partial && !$criteria) {
1802:                     return count($this->getMessageVersions());
1803:                 }
1804:                 $query = MessageVersionQuery::create(null, $criteria);
1805:                 if ($distinct) {
1806:                     $query->distinct();
1807:                 }
1808: 
1809:                 return $query
1810:                     ->filterByMessage($this)
1811:                     ->count($con);
1812:             }
1813:         } else {
1814:             return count($this->collMessageVersions);
1815:         }
1816:     }
1817: 
1818:     /**
1819:      * Method called to associate a MessageVersion object to this object
1820:      * through the MessageVersion foreign key attribute.
1821:      *
1822:      * @param    MessageVersion $l MessageVersion
1823:      * @return Message The current object (for fluent API support)
1824:      */
1825:     public function addMessageVersion(MessageVersion $l)
1826:     {
1827:         if ($this->collMessageVersions === null) {
1828:             $this->initMessageVersions();
1829:             $this->collMessageVersionsPartial = true;
1830:         }
1831:         if (!$this->collMessageVersions->contains($l)) { // only add it if the **same** object is not already associated
1832:             $this->doAddMessageVersion($l);
1833:         }
1834: 
1835:         return $this;
1836:     }
1837: 
1838:     /**
1839:      * @param   MessageVersion $messageVersion The messageVersion object to add.
1840:      */
1841:     protected function doAddMessageVersion($messageVersion)
1842:     {
1843:         $this->collMessageVersions[]= $messageVersion;
1844:         $messageVersion->setMessage($this);
1845:     }
1846: 
1847:     /**
1848:      * @param   MessageVersion $messageVersion The messageVersion object to remove.
1849:      */
1850:     public function removeMessageVersion($messageVersion)
1851:     {
1852:         if ($this->getMessageVersions()->contains($messageVersion)) {
1853:             $this->collMessageVersions->remove($this->collMessageVersions->search($messageVersion));
1854:             if (null === $this->messageVersionsScheduledForDeletion) {
1855:                 $this->messageVersionsScheduledForDeletion = clone $this->collMessageVersions;
1856:                 $this->messageVersionsScheduledForDeletion->clear();
1857:             }
1858:             $this->messageVersionsScheduledForDeletion[]= $messageVersion;
1859:             $messageVersion->setMessage(null);
1860:         }
1861:     }
1862: 
1863:     /**
1864:      * Clears the current object and sets all attributes to their default values
1865:      */
1866:     public function clear()
1867:     {
1868:         $this->id = null;
1869:         $this->code = null;
1870:         $this->secured = null;
1871:         $this->ref = null;
1872:         $this->created_at = null;
1873:         $this->updated_at = null;
1874:         $this->version = null;
1875:         $this->version_created_at = null;
1876:         $this->version_created_by = null;
1877:         $this->alreadyInSave = false;
1878:         $this->alreadyInValidation = false;
1879:         $this->clearAllReferences();
1880:         $this->applyDefaultValues();
1881:         $this->resetModified();
1882:         $this->setNew(true);
1883:         $this->setDeleted(false);
1884:     }
1885: 
1886:     /**
1887:      * Resets all references to other model objects or collections of model objects.
1888:      *
1889:      * This method is a user-space workaround for PHP's inability to garbage collect
1890:      * objects with circular references (even in PHP 5.3). This is currently necessary
1891:      * when using Propel in certain daemon or large-volumne/high-memory operations.
1892:      *
1893:      * @param boolean $deep Whether to also clear the references on all referrer objects.
1894:      */
1895:     public function clearAllReferences($deep = false)
1896:     {
1897:         if ($deep) {
1898:             if ($this->collMessageI18ns) {
1899:                 foreach ($this->collMessageI18ns as $o) {
1900:                     $o->clearAllReferences($deep);
1901:                 }
1902:             }
1903:             if ($this->collMessageVersions) {
1904:                 foreach ($this->collMessageVersions as $o) {
1905:                     $o->clearAllReferences($deep);
1906:                 }
1907:             }
1908:         } // if ($deep)
1909: 
1910:         // i18n behavior
1911:         $this->currentLocale = 'en_EN';
1912:         $this->currentTranslations = null;
1913: 
1914:         if ($this->collMessageI18ns instanceof PropelCollection) {
1915:             $this->collMessageI18ns->clearIterator();
1916:         }
1917:         $this->collMessageI18ns = null;
1918:         if ($this->collMessageVersions instanceof PropelCollection) {
1919:             $this->collMessageVersions->clearIterator();
1920:         }
1921:         $this->collMessageVersions = null;
1922:     }
1923: 
1924:     /**
1925:      * return the string representation of this object
1926:      *
1927:      * @return string
1928:      */
1929:     public function __toString()
1930:     {
1931:         return (string) $this->exportTo(MessagePeer::DEFAULT_STRING_FORMAT);
1932:     }
1933: 
1934:     /**
1935:      * return true is the object is in saving state
1936:      *
1937:      * @return boolean
1938:      */
1939:     public function isAlreadyInSave()
1940:     {
1941:         return $this->alreadyInSave;
1942:     }
1943: 
1944:     // timestampable behavior
1945: 
1946:     /**
1947:      * Mark the current object so that the update date doesn't get updated during next save
1948:      *
1949:      * @return     Message The current object (for fluent API support)
1950:      */
1951:     public function keepUpdateDateUnchanged()
1952:     {
1953:         $this->modifiedColumns[] = MessagePeer::UPDATED_AT;
1954: 
1955:         return $this;
1956:     }
1957: 
1958:     // i18n behavior
1959: 
1960:     /**
1961:      * Sets the locale for translations
1962:      *
1963:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
1964:      *
1965:      * @return    Message The current object (for fluent API support)
1966:      */
1967:     public function setLocale($locale = 'en_EN')
1968:     {
1969:         $this->currentLocale = $locale;
1970: 
1971:         return $this;
1972:     }
1973: 
1974:     /**
1975:      * Gets the locale for translations
1976:      *
1977:      * @return    string $locale Locale to use for the translation, e.g. 'fr_FR'
1978:      */
1979:     public function getLocale()
1980:     {
1981:         return $this->currentLocale;
1982:     }
1983: 
1984:     /**
1985:      * Returns the current translation for a given locale
1986:      *
1987:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
1988:      * @param     PropelPDO $con an optional connection object
1989:      *
1990:      * @return MessageI18n */
1991:     public function getTranslation($locale = 'en_EN', PropelPDO $con = null)
1992:     {
1993:         if (!isset($this->currentTranslations[$locale])) {
1994:             if (null !== $this->collMessageI18ns) {
1995:                 foreach ($this->collMessageI18ns as $translation) {
1996:                     if ($translation->getLocale() == $locale) {
1997:                         $this->currentTranslations[$locale] = $translation;
1998: 
1999:                         return $translation;
2000:                     }
2001:                 }
2002:             }
2003:             if ($this->isNew()) {
2004:                 $translation = new MessageI18n();
2005:                 $translation->setLocale($locale);
2006:             } else {
2007:                 $translation = MessageI18nQuery::create()
2008:                     ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
2009:                     ->findOneOrCreate($con);
2010:                 $this->currentTranslations[$locale] = $translation;
2011:             }
2012:             $this->addMessageI18n($translation);
2013:         }
2014: 
2015:         return $this->currentTranslations[$locale];
2016:     }
2017: 
2018:     /**
2019:      * Remove the translation for a given locale
2020:      *
2021:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
2022:      * @param     PropelPDO $con an optional connection object
2023:      *
2024:      * @return    Message The current object (for fluent API support)
2025:      */
2026:     public function removeTranslation($locale = 'en_EN', PropelPDO $con = null)
2027:     {
2028:         if (!$this->isNew()) {
2029:             MessageI18nQuery::create()
2030:                 ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
2031:                 ->delete($con);
2032:         }
2033:         if (isset($this->currentTranslations[$locale])) {
2034:             unset($this->currentTranslations[$locale]);
2035:         }
2036:         foreach ($this->collMessageI18ns as $key => $translation) {
2037:             if ($translation->getLocale() == $locale) {
2038:                 unset($this->collMessageI18ns[$key]);
2039:                 break;
2040:             }
2041:         }
2042: 
2043:         return $this;
2044:     }
2045: 
2046:     /**
2047:      * Returns the current translation
2048:      *
2049:      * @param     PropelPDO $con an optional connection object
2050:      *
2051:      * @return MessageI18n */
2052:     public function getCurrentTranslation(PropelPDO $con = null)
2053:     {
2054:         return $this->getTranslation($this->getLocale(), $con);
2055:     }
2056: 
2057: 
2058:         /**
2059:          * Get the [title] column value.
2060:          *
2061:          * @return string
2062:          */
2063:         public function getTitle()
2064:         {
2065:         return $this->getCurrentTranslation()->getTitle();
2066:     }
2067: 
2068: 
2069:         /**
2070:          * Set the value of [title] column.
2071:          *
2072:          * @param string $v new value
2073:          * @return MessageI18n The current object (for fluent API support)
2074:          */
2075:         public function setTitle($v)
2076:         {    $this->getCurrentTranslation()->setTitle($v);
2077: 
2078:         return $this;
2079:     }
2080: 
2081: 
2082:         /**
2083:          * Get the [description] column value.
2084:          *
2085:          * @return string
2086:          */
2087:         public function getDescription()
2088:         {
2089:         return $this->getCurrentTranslation()->getDescription();
2090:     }
2091: 
2092: 
2093:         /**
2094:          * Set the value of [description] column.
2095:          *
2096:          * @param string $v new value
2097:          * @return MessageI18n The current object (for fluent API support)
2098:          */
2099:         public function setDescription($v)
2100:         {    $this->getCurrentTranslation()->setDescription($v);
2101: 
2102:         return $this;
2103:     }
2104: 
2105: 
2106:         /**
2107:          * Get the [description_html] column value.
2108:          *
2109:          * @return string
2110:          */
2111:         public function getDescriptionHtml()
2112:         {
2113:         return $this->getCurrentTranslation()->getDescriptionHtml();
2114:     }
2115: 
2116: 
2117:         /**
2118:          * Set the value of [description_html] column.
2119:          *
2120:          * @param string $v new value
2121:          * @return MessageI18n The current object (for fluent API support)
2122:          */
2123:         public function setDescriptionHtml($v)
2124:         {    $this->getCurrentTranslation()->setDescriptionHtml($v);
2125: 
2126:         return $this;
2127:     }
2128: 
2129:     // versionable behavior
2130: 
2131:     /**
2132:      * Enforce a new Version of this object upon next save.
2133:      *
2134:      * @return Message
2135:      */
2136:     public function enforceVersioning()
2137:     {
2138:         $this->enforceVersion = true;
2139: 
2140:         return $this;
2141:     }
2142: 
2143:     /**
2144:      * Checks whether the current state must be recorded as a version
2145:      *
2146:      * @param PropelPDO $con An optional PropelPDO connection to use.
2147:      *
2148:      * @return  boolean
2149:      */
2150:     public function isVersioningNecessary($con = null)
2151:     {
2152:         if ($this->alreadyInSave) {
2153:             return false;
2154:         }
2155: 
2156:         if ($this->enforceVersion) {
2157:             return true;
2158:         }
2159: 
2160:         if (MessagePeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) {
2161:             return true;
2162:         }
2163: 
2164:         return false;
2165:     }
2166: 
2167:     /**
2168:      * Creates a version of the current object and saves it.
2169:      *
2170:      * @param   PropelPDO $con the connection to use
2171:      *
2172:      * @return  MessageVersion A version object
2173:      */
2174:     public function addVersion($con = null)
2175:     {
2176:         $this->enforceVersion = false;
2177: 
2178:         $version = new MessageVersion();
2179:         $version->setId($this->getId());
2180:         $version->setCode($this->getCode());
2181:         $version->setSecured($this->getSecured());
2182:         $version->setRef($this->getRef());
2183:         $version->setCreatedAt($this->getCreatedAt());
2184:         $version->setUpdatedAt($this->getUpdatedAt());
2185:         $version->setVersion($this->getVersion());
2186:         $version->setVersionCreatedAt($this->getVersionCreatedAt());
2187:         $version->setVersionCreatedBy($this->getVersionCreatedBy());
2188:         $version->setMessage($this);
2189:         $version->save($con);
2190: 
2191:         return $version;
2192:     }
2193: 
2194:     /**
2195:      * Sets the properties of the curent object to the value they had at a specific version
2196:      *
2197:      * @param   integer $versionNumber The version number to read
2198:      * @param   PropelPDO $con the connection to use
2199:      *
2200:      * @return  Message The current object (for fluent API support)
2201:      * @throws  PropelException - if no object with the given version can be found.
2202:      */
2203:     public function toVersion($versionNumber, $con = null)
2204:     {
2205:         $version = $this->getOneVersion($versionNumber, $con);
2206:         if (!$version) {
2207:             throw new PropelException(sprintf('No Message object found with version %d', $version));
2208:         }
2209:         $this->populateFromVersion($version, $con);
2210: 
2211:         return $this;
2212:     }
2213: 
2214:     /**
2215:      * Sets the properties of the curent object to the value they had at a specific version
2216:      *
2217:      * @param   MessageVersion $version The version object to use
2218:      * @param   PropelPDO $con the connection to use
2219:      * @param   array $loadedObjects objects thats been loaded in a chain of populateFromVersion calls on referrer or fk objects.
2220:      *
2221:      * @return  Message The current object (for fluent API support)
2222:      */
2223:     public function populateFromVersion($version, $con = null, &$loadedObjects = array())
2224:     {
2225: 
2226:         $loadedObjects['Message'][$version->getId()][$version->getVersion()] = $this;
2227:         $this->setId($version->getId());
2228:         $this->setCode($version->getCode());
2229:         $this->setSecured($version->getSecured());
2230:         $this->setRef($version->getRef());
2231:         $this->setCreatedAt($version->getCreatedAt());
2232:         $this->setUpdatedAt($version->getUpdatedAt());
2233:         $this->setVersion($version->getVersion());
2234:         $this->setVersionCreatedAt($version->getVersionCreatedAt());
2235:         $this->setVersionCreatedBy($version->getVersionCreatedBy());
2236: 
2237:         return $this;
2238:     }
2239: 
2240:     /**
2241:      * Gets the latest persisted version number for the current object
2242:      *
2243:      * @param   PropelPDO $con the connection to use
2244:      *
2245:      * @return  integer
2246:      */
2247:     public function getLastVersionNumber($con = null)
2248:     {
2249:         $v = MessageVersionQuery::create()
2250:             ->filterByMessage($this)
2251:             ->orderByVersion('desc')
2252:             ->findOne($con);
2253:         if (!$v) {
2254:             return 0;
2255:         }
2256: 
2257:         return $v->getVersion();
2258:     }
2259: 
2260:     /**
2261:      * Checks whether the current object is the latest one
2262:      *
2263:      * @param   PropelPDO $con the connection to use
2264:      *
2265:      * @return  boolean
2266:      */
2267:     public function isLastVersion($con = null)
2268:     {
2269:         return $this->getLastVersionNumber($con) == $this->getVersion();
2270:     }
2271: 
2272:     /**
2273:      * Retrieves a version object for this entity and a version number
2274:      *
2275:      * @param   integer $versionNumber The version number to read
2276:      * @param   PropelPDO $con the connection to use
2277:      *
2278:      * @return  MessageVersion A version object
2279:      */
2280:     public function getOneVersion($versionNumber, $con = null)
2281:     {
2282:         return MessageVersionQuery::create()
2283:             ->filterByMessage($this)
2284:             ->filterByVersion($versionNumber)
2285:             ->findOne($con);
2286:     }
2287: 
2288:     /**
2289:      * Gets all the versions of this object, in incremental order
2290:      *
2291:      * @param   PropelPDO $con the connection to use
2292:      *
2293:      * @return  PropelObjectCollection A list of MessageVersion objects
2294:      */
2295:     public function getAllVersions($con = null)
2296:     {
2297:         $criteria = new Criteria();
2298:         $criteria->addAscendingOrderByColumn(MessageVersionPeer::VERSION);
2299: 
2300:         return $this->getMessageVersions($criteria, $con);
2301:     }
2302: 
2303:     /**
2304:      * Compares the current object with another of its version.
2305:      * <code>
2306:      * print_r($book->compareVersion(1));
2307:      * => array(
2308:      *   '1' => array('Title' => 'Book title at version 1'),
2309:      *   '2' => array('Title' => 'Book title at version 2')
2310:      * );
2311:      * </code>
2312:      *
2313:      * @param   integer   $versionNumber
2314:      * @param   string    $keys Main key used for the result diff (versions|columns)
2315:      * @param   PropelPDO $con the connection to use
2316:      * @param   array     $ignoredColumns  The columns to exclude from the diff.
2317:      *
2318:      * @return  array A list of differences
2319:      */
2320:     public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
2321:     {
2322:         $fromVersion = $this->toArray();
2323:         $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
2324: 
2325:         return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
2326:     }
2327: 
2328:     /**
2329:      * Compares two versions of the current object.
2330:      * <code>
2331:      * print_r($book->compareVersions(1, 2));
2332:      * => array(
2333:      *   '1' => array('Title' => 'Book title at version 1'),
2334:      *   '2' => array('Title' => 'Book title at version 2')
2335:      * );
2336:      * </code>
2337:      *
2338:      * @param   integer   $fromVersionNumber
2339:      * @param   integer   $toVersionNumber
2340:      * @param   string    $keys Main key used for the result diff (versions|columns)
2341:      * @param   PropelPDO $con the connection to use
2342:      * @param   array     $ignoredColumns  The columns to exclude from the diff.
2343:      *
2344:      * @return  array A list of differences
2345:      */
2346:     public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
2347:     {
2348:         $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
2349:         $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
2350: 
2351:         return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
2352:     }
2353: 
2354:     /**
2355:      * Computes the diff between two versions.
2356:      * <code>
2357:      * print_r($this->computeDiff(1, 2));
2358:      * => array(
2359:      *   '1' => array('Title' => 'Book title at version 1'),
2360:      *   '2' => array('Title' => 'Book title at version 2')
2361:      * );
2362:      * </code>
2363:      *
2364:      * @param   array     $fromVersion     An array representing the original version.
2365:      * @param   array     $toVersion       An array representing the destination version.
2366:      * @param   string    $keys            Main key used for the result diff (versions|columns).
2367:      * @param   array     $ignoredColumns  The columns to exclude from the diff.
2368:      *
2369:      * @return  array A list of differences
2370:      */
2371:     protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
2372:     {
2373:         $fromVersionNumber = $fromVersion['Version'];
2374:         $toVersionNumber = $toVersion['Version'];
2375:         $ignoredColumns = array_merge(array(
2376:             'Version',
2377:             'VersionCreatedAt',
2378:             'VersionCreatedBy',
2379:         ), $ignoredColumns);
2380:         $diff = array();
2381:         foreach ($fromVersion as $key => $value) {
2382:             if (in_array($key, $ignoredColumns)) {
2383:                 continue;
2384:             }
2385:             if ($toVersion[$key] != $value) {
2386:                 switch ($keys) {
2387:                     case 'versions':
2388:                         $diff[$fromVersionNumber][$key] = $value;
2389:                         $diff[$toVersionNumber][$key] = $toVersion[$key];
2390:                         break;
2391:                     default:
2392:                         $diff[$key] = array(
2393:                             $fromVersionNumber => $value,
2394:                             $toVersionNumber => $toVersion[$key],
2395:                         );
2396:                         break;
2397:                 }
2398:             }
2399:         }
2400: 
2401:         return $diff;
2402:     }
2403:     /**
2404:      * retrieve the last $number versions.
2405:      *
2406:      * @param integer $number the number of record to return.
2407:      * @param MessageVersionQuery|Criteria $criteria Additional criteria to filter.
2408:      * @param PropelPDO $con An optional connection to use.
2409:      *
2410:      * @return PropelCollection|MessageVersion[] List of MessageVersion objects
2411:      */
2412:     public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null)
2413:     {
2414:         $criteria = MessageVersionQuery::create(null, $criteria);
2415:         $criteria->addDescendingOrderByColumn(MessageVersionPeer::VERSION);
2416:         $criteria->limit($number);
2417: 
2418:         return $this->getMessageVersions($criteria, $con);
2419:     }
2420: }
2421: 
thelia API documentation generated by ApiGen 2.8.0