Overview

Namespaces

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

Classes

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