Overview

Namespaces

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

Classes

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