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\ContentFolder;
  19: use Thelia\Model\ContentFolderQuery;
  20: use Thelia\Model\Document;
  21: use Thelia\Model\DocumentQuery;
  22: use Thelia\Model\Folder;
  23: use Thelia\Model\FolderI18n;
  24: use Thelia\Model\FolderI18nQuery;
  25: use Thelia\Model\FolderPeer;
  26: use Thelia\Model\FolderQuery;
  27: use Thelia\Model\FolderVersion;
  28: use Thelia\Model\FolderVersionPeer;
  29: use Thelia\Model\FolderVersionQuery;
  30: use Thelia\Model\Image;
  31: use Thelia\Model\ImageQuery;
  32: use Thelia\Model\Rewriting;
  33: use Thelia\Model\RewritingQuery;
  34: 
  35: /**
  36:  * Base class that represents a row from the 'folder' table.
  37:  *
  38:  *
  39:  *
  40:  * @package    propel.generator.Thelia.Model.om
  41:  */
  42: abstract class BaseFolder extends BaseObject implements Persistent
  43: {
  44:     /**
  45:      * Peer class name
  46:      */
  47:     const PEER = 'Thelia\\Model\\FolderPeer';
  48: 
  49:     /**
  50:      * The Peer class.
  51:      * Instance provides a convenient way of calling static methods on a class
  52:      * that calling code may not be able to identify.
  53:      * @var        FolderPeer
  54:      */
  55:     protected static $peer;
  56: 
  57:     /**
  58:      * The flag var to prevent infinit loop in deep copy
  59:      * @var       boolean
  60:      */
  61:     protected $startCopy = false;
  62: 
  63:     /**
  64:      * The value for the id field.
  65:      * @var        int
  66:      */
  67:     protected $id;
  68: 
  69:     /**
  70:      * The value for the parent field.
  71:      * @var        int
  72:      */
  73:     protected $parent;
  74: 
  75:     /**
  76:      * The value for the link field.
  77:      * @var        string
  78:      */
  79:     protected $link;
  80: 
  81:     /**
  82:      * The value for the visible field.
  83:      * @var        int
  84:      */
  85:     protected $visible;
  86: 
  87:     /**
  88:      * The value for the position field.
  89:      * @var        int
  90:      */
  91:     protected $position;
  92: 
  93:     /**
  94:      * The value for the created_at field.
  95:      * @var        string
  96:      */
  97:     protected $created_at;
  98: 
  99:     /**
 100:      * The value for the updated_at field.
 101:      * @var        string
 102:      */
 103:     protected $updated_at;
 104: 
 105:     /**
 106:      * The value for the version field.
 107:      * Note: this column has a database default value of: 0
 108:      * @var        int
 109:      */
 110:     protected $version;
 111: 
 112:     /**
 113:      * The value for the version_created_at field.
 114:      * @var        string
 115:      */
 116:     protected $version_created_at;
 117: 
 118:     /**
 119:      * The value for the version_created_by field.
 120:      * @var        string
 121:      */
 122:     protected $version_created_by;
 123: 
 124:     /**
 125:      * @var        PropelObjectCollection|Image[] Collection to store aggregation of Image objects.
 126:      */
 127:     protected $collImages;
 128:     protected $collImagesPartial;
 129: 
 130:     /**
 131:      * @var        PropelObjectCollection|Document[] Collection to store aggregation of Document objects.
 132:      */
 133:     protected $collDocuments;
 134:     protected $collDocumentsPartial;
 135: 
 136:     /**
 137:      * @var        PropelObjectCollection|Rewriting[] Collection to store aggregation of Rewriting objects.
 138:      */
 139:     protected $collRewritings;
 140:     protected $collRewritingsPartial;
 141: 
 142:     /**
 143:      * @var        PropelObjectCollection|ContentFolder[] Collection to store aggregation of ContentFolder objects.
 144:      */
 145:     protected $collContentFolders;
 146:     protected $collContentFoldersPartial;
 147: 
 148:     /**
 149:      * @var        PropelObjectCollection|FolderI18n[] Collection to store aggregation of FolderI18n objects.
 150:      */
 151:     protected $collFolderI18ns;
 152:     protected $collFolderI18nsPartial;
 153: 
 154:     /**
 155:      * @var        PropelObjectCollection|FolderVersion[] Collection to store aggregation of FolderVersion objects.
 156:      */
 157:     protected $collFolderVersions;
 158:     protected $collFolderVersionsPartial;
 159: 
 160:     /**
 161:      * Flag to prevent endless save loop, if this object is referenced
 162:      * by another object which falls in this transaction.
 163:      * @var        boolean
 164:      */
 165:     protected $alreadyInSave = false;
 166: 
 167:     /**
 168:      * Flag to prevent endless validation loop, if this object is referenced
 169:      * by another object which falls in this transaction.
 170:      * @var        boolean
 171:      */
 172:     protected $alreadyInValidation = false;
 173: 
 174:     // i18n behavior
 175: 
 176:     /**
 177:      * Current locale
 178:      * @var        string
 179:      */
 180:     protected $currentLocale = 'en_EN';
 181: 
 182:     /**
 183:      * Current translation objects
 184:      * @var        array[FolderI18n]
 185:      */
 186:     protected $currentTranslations;
 187: 
 188:     // versionable behavior
 189: 
 190: 
 191:     /**
 192:      * @var bool
 193:      */
 194:     protected $enforceVersion = false;
 195: 
 196:     /**
 197:      * An array of objects scheduled for deletion.
 198:      * @var     PropelObjectCollection
 199:      */
 200:     protected $imagesScheduledForDeletion = null;
 201: 
 202:     /**
 203:      * An array of objects scheduled for deletion.
 204:      * @var     PropelObjectCollection
 205:      */
 206:     protected $documentsScheduledForDeletion = null;
 207: 
 208:     /**
 209:      * An array of objects scheduled for deletion.
 210:      * @var     PropelObjectCollection
 211:      */
 212:     protected $rewritingsScheduledForDeletion = null;
 213: 
 214:     /**
 215:      * An array of objects scheduled for deletion.
 216:      * @var     PropelObjectCollection
 217:      */
 218:     protected $contentFoldersScheduledForDeletion = null;
 219: 
 220:     /**
 221:      * An array of objects scheduled for deletion.
 222:      * @var     PropelObjectCollection
 223:      */
 224:     protected $folderI18nsScheduledForDeletion = null;
 225: 
 226:     /**
 227:      * An array of objects scheduled for deletion.
 228:      * @var     PropelObjectCollection
 229:      */
 230:     protected $folderVersionsScheduledForDeletion = null;
 231: 
 232:     /**
 233:      * Applies default values to this object.
 234:      * This method should be called from the object's constructor (or
 235:      * equivalent initialization method).
 236:      * @see        __construct()
 237:      */
 238:     public function applyDefaultValues()
 239:     {
 240:         $this->version = 0;
 241:     }
 242: 
 243:     /**
 244:      * Initializes internal state of BaseFolder object.
 245:      * @see        applyDefaults()
 246:      */
 247:     public function __construct()
 248:     {
 249:         parent::__construct();
 250:         $this->applyDefaultValues();
 251:     }
 252: 
 253:     /**
 254:      * Get the [id] column value.
 255:      *
 256:      * @return int
 257:      */
 258:     public function getId()
 259:     {
 260:         return $this->id;
 261:     }
 262: 
 263:     /**
 264:      * Get the [parent] column value.
 265:      *
 266:      * @return int
 267:      */
 268:     public function getParent()
 269:     {
 270:         return $this->parent;
 271:     }
 272: 
 273:     /**
 274:      * Get the [link] column value.
 275:      *
 276:      * @return string
 277:      */
 278:     public function getLink()
 279:     {
 280:         return $this->link;
 281:     }
 282: 
 283:     /**
 284:      * Get the [visible] column value.
 285:      *
 286:      * @return int
 287:      */
 288:     public function getVisible()
 289:     {
 290:         return $this->visible;
 291:     }
 292: 
 293:     /**
 294:      * Get the [position] column value.
 295:      *
 296:      * @return int
 297:      */
 298:     public function getPosition()
 299:     {
 300:         return $this->position;
 301:     }
 302: 
 303:     /**
 304:      * Get the [optionally formatted] temporal [created_at] column value.
 305:      *
 306:      *
 307:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 308:      *               If format is null, then the raw DateTime object will be returned.
 309:      * @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
 310:      * @throws PropelException - if unable to parse/validate the date/time value.
 311:      */
 312:     public function getCreatedAt($format = 'Y-m-d H:i:s')
 313:     {
 314:         if ($this->created_at === null) {
 315:             return null;
 316:         }
 317: 
 318:         if ($this->created_at === '0000-00-00 00:00:00') {
 319:             // while technically this is not a default value of null,
 320:             // this seems to be closest in meaning.
 321:             return null;
 322:         } else {
 323:             try {
 324:                 $dt = new DateTime($this->created_at);
 325:             } catch (Exception $x) {
 326:                 throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
 327:             }
 328:         }
 329: 
 330:         if ($format === null) {
 331:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 332:             return $dt;
 333:         } elseif (strpos($format, '%') !== false) {
 334:             return strftime($format, $dt->format('U'));
 335:         } else {
 336:             return $dt->format($format);
 337:         }
 338:     }
 339: 
 340:     /**
 341:      * Get the [optionally formatted] temporal [updated_at] column value.
 342:      *
 343:      *
 344:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 345:      *               If format is null, then the raw DateTime object will be returned.
 346:      * @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
 347:      * @throws PropelException - if unable to parse/validate the date/time value.
 348:      */
 349:     public function getUpdatedAt($format = 'Y-m-d H:i:s')
 350:     {
 351:         if ($this->updated_at === null) {
 352:             return null;
 353:         }
 354: 
 355:         if ($this->updated_at === '0000-00-00 00:00:00') {
 356:             // while technically this is not a default value of null,
 357:             // this seems to be closest in meaning.
 358:             return null;
 359:         } else {
 360:             try {
 361:                 $dt = new DateTime($this->updated_at);
 362:             } catch (Exception $x) {
 363:                 throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
 364:             }
 365:         }
 366: 
 367:         if ($format === null) {
 368:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 369:             return $dt;
 370:         } elseif (strpos($format, '%') !== false) {
 371:             return strftime($format, $dt->format('U'));
 372:         } else {
 373:             return $dt->format($format);
 374:         }
 375:     }
 376: 
 377:     /**
 378:      * Get the [version] column value.
 379:      *
 380:      * @return int
 381:      */
 382:     public function getVersion()
 383:     {
 384:         return $this->version;
 385:     }
 386: 
 387:     /**
 388:      * Get the [optionally formatted] temporal [version_created_at] column value.
 389:      *
 390:      *
 391:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 392:      *               If format is null, then the raw DateTime object will be returned.
 393:      * @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
 394:      * @throws PropelException - if unable to parse/validate the date/time value.
 395:      */
 396:     public function getVersionCreatedAt($format = 'Y-m-d H:i:s')
 397:     {
 398:         if ($this->version_created_at === null) {
 399:             return null;
 400:         }
 401: 
 402:         if ($this->version_created_at === '0000-00-00 00:00:00') {
 403:             // while technically this is not a default value of null,
 404:             // this seems to be closest in meaning.
 405:             return null;
 406:         } else {
 407:             try {
 408:                 $dt = new DateTime($this->version_created_at);
 409:             } catch (Exception $x) {
 410:                 throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
 411:             }
 412:         }
 413: 
 414:         if ($format === null) {
 415:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 416:             return $dt;
 417:         } elseif (strpos($format, '%') !== false) {
 418:             return strftime($format, $dt->format('U'));
 419:         } else {
 420:             return $dt->format($format);
 421:         }
 422:     }
 423: 
 424:     /**
 425:      * Get the [version_created_by] column value.
 426:      *
 427:      * @return string
 428:      */
 429:     public function getVersionCreatedBy()
 430:     {
 431:         return $this->version_created_by;
 432:     }
 433: 
 434:     /**
 435:      * Set the value of [id] column.
 436:      *
 437:      * @param int $v new value
 438:      * @return Folder The current object (for fluent API support)
 439:      */
 440:     public function setId($v)
 441:     {
 442:         if ($v !== null) {
 443:             $v = (int) $v;
 444:         }
 445: 
 446:         if ($this->id !== $v) {
 447:             $this->id = $v;
 448:             $this->modifiedColumns[] = FolderPeer::ID;
 449:         }
 450: 
 451: 
 452:         return $this;
 453:     } // setId()
 454: 
 455:     /**
 456:      * Set the value of [parent] column.
 457:      *
 458:      * @param int $v new value
 459:      * @return Folder The current object (for fluent API support)
 460:      */
 461:     public function setParent($v)
 462:     {
 463:         if ($v !== null) {
 464:             $v = (int) $v;
 465:         }
 466: 
 467:         if ($this->parent !== $v) {
 468:             $this->parent = $v;
 469:             $this->modifiedColumns[] = FolderPeer::PARENT;
 470:         }
 471: 
 472: 
 473:         return $this;
 474:     } // setParent()
 475: 
 476:     /**
 477:      * Set the value of [link] column.
 478:      *
 479:      * @param string $v new value
 480:      * @return Folder The current object (for fluent API support)
 481:      */
 482:     public function setLink($v)
 483:     {
 484:         if ($v !== null) {
 485:             $v = (string) $v;
 486:         }
 487: 
 488:         if ($this->link !== $v) {
 489:             $this->link = $v;
 490:             $this->modifiedColumns[] = FolderPeer::LINK;
 491:         }
 492: 
 493: 
 494:         return $this;
 495:     } // setLink()
 496: 
 497:     /**
 498:      * Set the value of [visible] column.
 499:      *
 500:      * @param int $v new value
 501:      * @return Folder The current object (for fluent API support)
 502:      */
 503:     public function setVisible($v)
 504:     {
 505:         if ($v !== null) {
 506:             $v = (int) $v;
 507:         }
 508: 
 509:         if ($this->visible !== $v) {
 510:             $this->visible = $v;
 511:             $this->modifiedColumns[] = FolderPeer::VISIBLE;
 512:         }
 513: 
 514: 
 515:         return $this;
 516:     } // setVisible()
 517: 
 518:     /**
 519:      * Set the value of [position] column.
 520:      *
 521:      * @param int $v new value
 522:      * @return Folder The current object (for fluent API support)
 523:      */
 524:     public function setPosition($v)
 525:     {
 526:         if ($v !== null) {
 527:             $v = (int) $v;
 528:         }
 529: 
 530:         if ($this->position !== $v) {
 531:             $this->position = $v;
 532:             $this->modifiedColumns[] = FolderPeer::POSITION;
 533:         }
 534: 
 535: 
 536:         return $this;
 537:     } // setPosition()
 538: 
 539:     /**
 540:      * Sets the value of [created_at] column to a normalized version of the date/time value specified.
 541:      *
 542:      * @param mixed $v string, integer (timestamp), or DateTime value.
 543:      *               Empty strings are treated as null.
 544:      * @return Folder The current object (for fluent API support)
 545:      */
 546:     public function setCreatedAt($v)
 547:     {
 548:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 549:         if ($this->created_at !== null || $dt !== null) {
 550:             $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 551:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 552:             if ($currentDateAsString !== $newDateAsString) {
 553:                 $this->created_at = $newDateAsString;
 554:                 $this->modifiedColumns[] = FolderPeer::CREATED_AT;
 555:             }
 556:         } // if either are not null
 557: 
 558: 
 559:         return $this;
 560:     } // setCreatedAt()
 561: 
 562:     /**
 563:      * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
 564:      *
 565:      * @param mixed $v string, integer (timestamp), or DateTime value.
 566:      *               Empty strings are treated as null.
 567:      * @return Folder The current object (for fluent API support)
 568:      */
 569:     public function setUpdatedAt($v)
 570:     {
 571:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 572:         if ($this->updated_at !== null || $dt !== null) {
 573:             $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 574:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 575:             if ($currentDateAsString !== $newDateAsString) {
 576:                 $this->updated_at = $newDateAsString;
 577:                 $this->modifiedColumns[] = FolderPeer::UPDATED_AT;
 578:             }
 579:         } // if either are not null
 580: 
 581: 
 582:         return $this;
 583:     } // setUpdatedAt()
 584: 
 585:     /**
 586:      * Set the value of [version] column.
 587:      *
 588:      * @param int $v new value
 589:      * @return Folder The current object (for fluent API support)
 590:      */
 591:     public function setVersion($v)
 592:     {
 593:         if ($v !== null) {
 594:             $v = (int) $v;
 595:         }
 596: 
 597:         if ($this->version !== $v) {
 598:             $this->version = $v;
 599:             $this->modifiedColumns[] = FolderPeer::VERSION;
 600:         }
 601: 
 602: 
 603:         return $this;
 604:     } // setVersion()
 605: 
 606:     /**
 607:      * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
 608:      *
 609:      * @param mixed $v string, integer (timestamp), or DateTime value.
 610:      *               Empty strings are treated as null.
 611:      * @return Folder The current object (for fluent API support)
 612:      */
 613:     public function setVersionCreatedAt($v)
 614:     {
 615:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 616:         if ($this->version_created_at !== null || $dt !== null) {
 617:             $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 618:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 619:             if ($currentDateAsString !== $newDateAsString) {
 620:                 $this->version_created_at = $newDateAsString;
 621:                 $this->modifiedColumns[] = FolderPeer::VERSION_CREATED_AT;
 622:             }
 623:         } // if either are not null
 624: 
 625: 
 626:         return $this;
 627:     } // setVersionCreatedAt()
 628: 
 629:     /**
 630:      * Set the value of [version_created_by] column.
 631:      *
 632:      * @param string $v new value
 633:      * @return Folder The current object (for fluent API support)
 634:      */
 635:     public function setVersionCreatedBy($v)
 636:     {
 637:         if ($v !== null) {
 638:             $v = (string) $v;
 639:         }
 640: 
 641:         if ($this->version_created_by !== $v) {
 642:             $this->version_created_by = $v;
 643:             $this->modifiedColumns[] = FolderPeer::VERSION_CREATED_BY;
 644:         }
 645: 
 646: 
 647:         return $this;
 648:     } // setVersionCreatedBy()
 649: 
 650:     /**
 651:      * Indicates whether the columns in this object are only set to default values.
 652:      *
 653:      * This method can be used in conjunction with isModified() to indicate whether an object is both
 654:      * modified _and_ has some values set which are non-default.
 655:      *
 656:      * @return boolean Whether the columns in this object are only been set with default values.
 657:      */
 658:     public function hasOnlyDefaultValues()
 659:     {
 660:             if ($this->version !== 0) {
 661:                 return false;
 662:             }
 663: 
 664:         // otherwise, everything was equal, so return true
 665:         return true;
 666:     } // hasOnlyDefaultValues()
 667: 
 668:     /**
 669:      * Hydrates (populates) the object variables with values from the database resultset.
 670:      *
 671:      * An offset (0-based "start column") is specified so that objects can be hydrated
 672:      * with a subset of the columns in the resultset rows.  This is needed, for example,
 673:      * for results of JOIN queries where the resultset row includes columns from two or
 674:      * more tables.
 675:      *
 676:      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
 677:      * @param int $startcol 0-based offset column which indicates which restultset column to start with.
 678:      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
 679:      * @return int             next starting column
 680:      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
 681:      */
 682:     public function hydrate($row, $startcol = 0, $rehydrate = false)
 683:     {
 684:         try {
 685: 
 686:             $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
 687:             $this->parent = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
 688:             $this->link = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
 689:             $this->visible = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
 690:             $this->position = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
 691:             $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
 692:             $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
 693:             $this->version = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
 694:             $this->version_created_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
 695:             $this->version_created_by = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
 696:             $this->resetModified();
 697: 
 698:             $this->setNew(false);
 699: 
 700:             if ($rehydrate) {
 701:                 $this->ensureConsistency();
 702:             }
 703: 
 704:             return $startcol + 10; // 10 = FolderPeer::NUM_HYDRATE_COLUMNS.
 705: 
 706:         } catch (Exception $e) {
 707:             throw new PropelException("Error populating Folder object", $e);
 708:         }
 709:     }
 710: 
 711:     /**
 712:      * Checks and repairs the internal consistency of the object.
 713:      *
 714:      * This method is executed after an already-instantiated object is re-hydrated
 715:      * from the database.  It exists to check any foreign keys to make sure that
 716:      * the objects related to the current object are correct based on foreign key.
 717:      *
 718:      * You can override this method in the stub class, but you should always invoke
 719:      * the base method from the overridden method (i.e. parent::ensureConsistency()),
 720:      * in case your model changes.
 721:      *
 722:      * @throws PropelException
 723:      */
 724:     public function ensureConsistency()
 725:     {
 726: 
 727:     } // ensureConsistency
 728: 
 729:     /**
 730:      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
 731:      *
 732:      * This will only work if the object has been saved and has a valid primary key set.
 733:      *
 734:      * @param boolean $deep (optional) Whether to also de-associated any related objects.
 735:      * @param PropelPDO $con (optional) The PropelPDO connection to use.
 736:      * @return void
 737:      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
 738:      */
 739:     public function reload($deep = false, PropelPDO $con = null)
 740:     {
 741:         if ($this->isDeleted()) {
 742:             throw new PropelException("Cannot reload a deleted object.");
 743:         }
 744: 
 745:         if ($this->isNew()) {
 746:             throw new PropelException("Cannot reload an unsaved object.");
 747:         }
 748: 
 749:         if ($con === null) {
 750:             $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
 751:         }
 752: 
 753:         // We don't need to alter the object instance pool; we're just modifying this instance
 754:         // already in the pool.
 755: 
 756:         $stmt = FolderPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
 757:         $row = $stmt->fetch(PDO::FETCH_NUM);
 758:         $stmt->closeCursor();
 759:         if (!$row) {
 760:             throw new PropelException('Cannot find matching row in the database to reload object values.');
 761:         }
 762:         $this->hydrate($row, 0, true); // rehydrate
 763: 
 764:         if ($deep) {  // also de-associate any related objects?
 765: 
 766:             $this->collImages = null;
 767: 
 768:             $this->collDocuments = null;
 769: 
 770:             $this->collRewritings = null;
 771: 
 772:             $this->collContentFolders = null;
 773: 
 774:             $this->collFolderI18ns = null;
 775: 
 776:             $this->collFolderVersions = null;
 777: 
 778:         } // if (deep)
 779:     }
 780: 
 781:     /**
 782:      * Removes this object from datastore and sets delete attribute.
 783:      *
 784:      * @param PropelPDO $con
 785:      * @return void
 786:      * @throws PropelException
 787:      * @throws Exception
 788:      * @see        BaseObject::setDeleted()
 789:      * @see        BaseObject::isDeleted()
 790:      */
 791:     public function delete(PropelPDO $con = null)
 792:     {
 793:         if ($this->isDeleted()) {
 794:             throw new PropelException("This object has already been deleted.");
 795:         }
 796: 
 797:         if ($con === null) {
 798:             $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 799:         }
 800: 
 801:         $con->beginTransaction();
 802:         try {
 803:             $deleteQuery = FolderQuery::create()
 804:                 ->filterByPrimaryKey($this->getPrimaryKey());
 805:             $ret = $this->preDelete($con);
 806:             if ($ret) {
 807:                 $deleteQuery->delete($con);
 808:                 $this->postDelete($con);
 809:                 $con->commit();
 810:                 $this->setDeleted(true);
 811:             } else {
 812:                 $con->commit();
 813:             }
 814:         } catch (Exception $e) {
 815:             $con->rollBack();
 816:             throw $e;
 817:         }
 818:     }
 819: 
 820:     /**
 821:      * Persists this object to the database.
 822:      *
 823:      * If the object is new, it inserts it; otherwise an update is performed.
 824:      * All modified related objects will also be persisted in the doSave()
 825:      * method.  This method wraps all precipitate database operations in a
 826:      * single transaction.
 827:      *
 828:      * @param PropelPDO $con
 829:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 830:      * @throws PropelException
 831:      * @throws Exception
 832:      * @see        doSave()
 833:      */
 834:     public function save(PropelPDO $con = null)
 835:     {
 836:         if ($this->isDeleted()) {
 837:             throw new PropelException("You cannot save an object that has been deleted.");
 838:         }
 839: 
 840:         if ($con === null) {
 841:             $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 842:         }
 843: 
 844:         $con->beginTransaction();
 845:         $isInsert = $this->isNew();
 846:         try {
 847:             $ret = $this->preSave($con);
 848:             // versionable behavior
 849:             if ($this->isVersioningNecessary()) {
 850:                 $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
 851:                 if (!$this->isColumnModified(FolderPeer::VERSION_CREATED_AT)) {
 852:                     $this->setVersionCreatedAt(time());
 853:                 }
 854:                 $createVersion = true; // for postSave hook
 855:             }
 856:             if ($isInsert) {
 857:                 $ret = $ret && $this->preInsert($con);
 858:                 // timestampable behavior
 859:                 if (!$this->isColumnModified(FolderPeer::CREATED_AT)) {
 860:                     $this->setCreatedAt(time());
 861:                 }
 862:                 if (!$this->isColumnModified(FolderPeer::UPDATED_AT)) {
 863:                     $this->setUpdatedAt(time());
 864:                 }
 865:             } else {
 866:                 $ret = $ret && $this->preUpdate($con);
 867:                 // timestampable behavior
 868:                 if ($this->isModified() && !$this->isColumnModified(FolderPeer::UPDATED_AT)) {
 869:                     $this->setUpdatedAt(time());
 870:                 }
 871:             }
 872:             if ($ret) {
 873:                 $affectedRows = $this->doSave($con);
 874:                 if ($isInsert) {
 875:                     $this->postInsert($con);
 876:                 } else {
 877:                     $this->postUpdate($con);
 878:                 }
 879:                 $this->postSave($con);
 880:                 // versionable behavior
 881:                 if (isset($createVersion)) {
 882:                     $this->addVersion($con);
 883:                 }
 884:                 FolderPeer::addInstanceToPool($this);
 885:             } else {
 886:                 $affectedRows = 0;
 887:             }
 888:             $con->commit();
 889: 
 890:             return $affectedRows;
 891:         } catch (Exception $e) {
 892:             $con->rollBack();
 893:             throw $e;
 894:         }
 895:     }
 896: 
 897:     /**
 898:      * Performs the work of inserting or updating the row in the database.
 899:      *
 900:      * If the object is new, it inserts it; otherwise an update is performed.
 901:      * All related objects are also updated in this method.
 902:      *
 903:      * @param PropelPDO $con
 904:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 905:      * @throws PropelException
 906:      * @see        save()
 907:      */
 908:     protected function doSave(PropelPDO $con)
 909:     {
 910:         $affectedRows = 0; // initialize var to track total num of affected rows
 911:         if (!$this->alreadyInSave) {
 912:             $this->alreadyInSave = true;
 913: 
 914:             if ($this->isNew() || $this->isModified()) {
 915:                 // persist changes
 916:                 if ($this->isNew()) {
 917:                     $this->doInsert($con);
 918:                 } else {
 919:                     $this->doUpdate($con);
 920:                 }
 921:                 $affectedRows += 1;
 922:                 $this->resetModified();
 923:             }
 924: 
 925:             if ($this->imagesScheduledForDeletion !== null) {
 926:                 if (!$this->imagesScheduledForDeletion->isEmpty()) {
 927:                     foreach ($this->imagesScheduledForDeletion as $image) {
 928:                         // need to save related object because we set the relation to null
 929:                         $image->save($con);
 930:                     }
 931:                     $this->imagesScheduledForDeletion = null;
 932:                 }
 933:             }
 934: 
 935:             if ($this->collImages !== null) {
 936:                 foreach ($this->collImages as $referrerFK) {
 937:                     if (!$referrerFK->isDeleted()) {
 938:                         $affectedRows += $referrerFK->save($con);
 939:                     }
 940:                 }
 941:             }
 942: 
 943:             if ($this->documentsScheduledForDeletion !== null) {
 944:                 if (!$this->documentsScheduledForDeletion->isEmpty()) {
 945:                     foreach ($this->documentsScheduledForDeletion as $document) {
 946:                         // need to save related object because we set the relation to null
 947:                         $document->save($con);
 948:                     }
 949:                     $this->documentsScheduledForDeletion = null;
 950:                 }
 951:             }
 952: 
 953:             if ($this->collDocuments !== null) {
 954:                 foreach ($this->collDocuments as $referrerFK) {
 955:                     if (!$referrerFK->isDeleted()) {
 956:                         $affectedRows += $referrerFK->save($con);
 957:                     }
 958:                 }
 959:             }
 960: 
 961:             if ($this->rewritingsScheduledForDeletion !== null) {
 962:                 if (!$this->rewritingsScheduledForDeletion->isEmpty()) {
 963:                     foreach ($this->rewritingsScheduledForDeletion as $rewriting) {
 964:                         // need to save related object because we set the relation to null
 965:                         $rewriting->save($con);
 966:                     }
 967:                     $this->rewritingsScheduledForDeletion = null;
 968:                 }
 969:             }
 970: 
 971:             if ($this->collRewritings !== null) {
 972:                 foreach ($this->collRewritings as $referrerFK) {
 973:                     if (!$referrerFK->isDeleted()) {
 974:                         $affectedRows += $referrerFK->save($con);
 975:                     }
 976:                 }
 977:             }
 978: 
 979:             if ($this->contentFoldersScheduledForDeletion !== null) {
 980:                 if (!$this->contentFoldersScheduledForDeletion->isEmpty()) {
 981:                     ContentFolderQuery::create()
 982:                         ->filterByPrimaryKeys($this->contentFoldersScheduledForDeletion->getPrimaryKeys(false))
 983:                         ->delete($con);
 984:                     $this->contentFoldersScheduledForDeletion = null;
 985:                 }
 986:             }
 987: 
 988:             if ($this->collContentFolders !== null) {
 989:                 foreach ($this->collContentFolders as $referrerFK) {
 990:                     if (!$referrerFK->isDeleted()) {
 991:                         $affectedRows += $referrerFK->save($con);
 992:                     }
 993:                 }
 994:             }
 995: 
 996:             if ($this->folderI18nsScheduledForDeletion !== null) {
 997:                 if (!$this->folderI18nsScheduledForDeletion->isEmpty()) {
 998:                     FolderI18nQuery::create()
 999:                         ->filterByPrimaryKeys($this->folderI18nsScheduledForDeletion->getPrimaryKeys(false))
1000:                         ->delete($con);
1001:                     $this->folderI18nsScheduledForDeletion = null;
1002:                 }
1003:             }
1004: 
1005:             if ($this->collFolderI18ns !== null) {
1006:                 foreach ($this->collFolderI18ns as $referrerFK) {
1007:                     if (!$referrerFK->isDeleted()) {
1008:                         $affectedRows += $referrerFK->save($con);
1009:                     }
1010:                 }
1011:             }
1012: 
1013:             if ($this->folderVersionsScheduledForDeletion !== null) {
1014:                 if (!$this->folderVersionsScheduledForDeletion->isEmpty()) {
1015:                     FolderVersionQuery::create()
1016:                         ->filterByPrimaryKeys($this->folderVersionsScheduledForDeletion->getPrimaryKeys(false))
1017:                         ->delete($con);
1018:                     $this->folderVersionsScheduledForDeletion = null;
1019:                 }
1020:             }
1021: 
1022:             if ($this->collFolderVersions !== null) {
1023:                 foreach ($this->collFolderVersions as $referrerFK) {
1024:                     if (!$referrerFK->isDeleted()) {
1025:                         $affectedRows += $referrerFK->save($con);
1026:                     }
1027:                 }
1028:             }
1029: 
1030:             $this->alreadyInSave = false;
1031: 
1032:         }
1033: 
1034:         return $affectedRows;
1035:     } // doSave()
1036: 
1037:     /**
1038:      * Insert the row in the database.
1039:      *
1040:      * @param PropelPDO $con
1041:      *
1042:      * @throws PropelException
1043:      * @see        doSave()
1044:      */
1045:     protected function doInsert(PropelPDO $con)
1046:     {
1047:         $modifiedColumns = array();
1048:         $index = 0;
1049: 
1050:         $this->modifiedColumns[] = FolderPeer::ID;
1051:         if (null !== $this->id) {
1052:             throw new PropelException('Cannot insert a value for auto-increment primary key (' . FolderPeer::ID . ')');
1053:         }
1054: 
1055:          // check the columns in natural order for more readable SQL queries
1056:         if ($this->isColumnModified(FolderPeer::ID)) {
1057:             $modifiedColumns[':p' . $index++]  = '`ID`';
1058:         }
1059:         if ($this->isColumnModified(FolderPeer::PARENT)) {
1060:             $modifiedColumns[':p' . $index++]  = '`PARENT`';
1061:         }
1062:         if ($this->isColumnModified(FolderPeer::LINK)) {
1063:             $modifiedColumns[':p' . $index++]  = '`LINK`';
1064:         }
1065:         if ($this->isColumnModified(FolderPeer::VISIBLE)) {
1066:             $modifiedColumns[':p' . $index++]  = '`VISIBLE`';
1067:         }
1068:         if ($this->isColumnModified(FolderPeer::POSITION)) {
1069:             $modifiedColumns[':p' . $index++]  = '`POSITION`';
1070:         }
1071:         if ($this->isColumnModified(FolderPeer::CREATED_AT)) {
1072:             $modifiedColumns[':p' . $index++]  = '`CREATED_AT`';
1073:         }
1074:         if ($this->isColumnModified(FolderPeer::UPDATED_AT)) {
1075:             $modifiedColumns[':p' . $index++]  = '`UPDATED_AT`';
1076:         }
1077:         if ($this->isColumnModified(FolderPeer::VERSION)) {
1078:             $modifiedColumns[':p' . $index++]  = '`VERSION`';
1079:         }
1080:         if ($this->isColumnModified(FolderPeer::VERSION_CREATED_AT)) {
1081:             $modifiedColumns[':p' . $index++]  = '`VERSION_CREATED_AT`';
1082:         }
1083:         if ($this->isColumnModified(FolderPeer::VERSION_CREATED_BY)) {
1084:             $modifiedColumns[':p' . $index++]  = '`VERSION_CREATED_BY`';
1085:         }
1086: 
1087:         $sql = sprintf(
1088:             'INSERT INTO `folder` (%s) VALUES (%s)',
1089:             implode(', ', $modifiedColumns),
1090:             implode(', ', array_keys($modifiedColumns))
1091:         );
1092: 
1093:         try {
1094:             $stmt = $con->prepare($sql);
1095:             foreach ($modifiedColumns as $identifier => $columnName) {
1096:                 switch ($columnName) {
1097:                     case '`ID`':
1098:                         $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
1099:                         break;
1100:                     case '`PARENT`':
1101:                         $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT);
1102:                         break;
1103:                     case '`LINK`':
1104:                         $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR);
1105:                         break;
1106:                     case '`VISIBLE`':
1107:                         $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
1108:                         break;
1109:                     case '`POSITION`':
1110:                         $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
1111:                         break;
1112:                     case '`CREATED_AT`':
1113:                         $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
1114:                         break;
1115:                     case '`UPDATED_AT`':
1116:                         $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
1117:                         break;
1118:                     case '`VERSION`':
1119:                         $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
1120:                         break;
1121:                     case '`VERSION_CREATED_AT`':
1122:                         $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
1123:                         break;
1124:                     case '`VERSION_CREATED_BY`':
1125:                         $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
1126:                         break;
1127:                 }
1128:             }
1129:             $stmt->execute();
1130:         } catch (Exception $e) {
1131:             Propel::log($e->getMessage(), Propel::LOG_ERR);
1132:             throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
1133:         }
1134: 
1135:         try {
1136:             $pk = $con->lastInsertId();
1137:         } catch (Exception $e) {
1138:             throw new PropelException('Unable to get autoincrement id.', $e);
1139:         }
1140:         $this->setId($pk);
1141: 
1142:         $this->setNew(false);
1143:     }
1144: 
1145:     /**
1146:      * Update the row in the database.
1147:      *
1148:      * @param PropelPDO $con
1149:      *
1150:      * @see        doSave()
1151:      */
1152:     protected function doUpdate(PropelPDO $con)
1153:     {
1154:         $selectCriteria = $this->buildPkeyCriteria();
1155:         $valuesCriteria = $this->buildCriteria();
1156:         BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
1157:     }
1158: 
1159:     /**
1160:      * Array of ValidationFailed objects.
1161:      * @var        array ValidationFailed[]
1162:      */
1163:     protected $validationFailures = array();
1164: 
1165:     /**
1166:      * Gets any ValidationFailed objects that resulted from last call to validate().
1167:      *
1168:      *
1169:      * @return array ValidationFailed[]
1170:      * @see        validate()
1171:      */
1172:     public function getValidationFailures()
1173:     {
1174:         return $this->validationFailures;
1175:     }
1176: 
1177:     /**
1178:      * Validates the objects modified field values and all objects related to this table.
1179:      *
1180:      * If $columns is either a column name or an array of column names
1181:      * only those columns are validated.
1182:      *
1183:      * @param mixed $columns Column name or an array of column names.
1184:      * @return boolean Whether all columns pass validation.
1185:      * @see        doValidate()
1186:      * @see        getValidationFailures()
1187:      */
1188:     public function validate($columns = null)
1189:     {
1190:         $res = $this->doValidate($columns);
1191:         if ($res === true) {
1192:             $this->validationFailures = array();
1193: 
1194:             return true;
1195:         } else {
1196:             $this->validationFailures = $res;
1197: 
1198:             return false;
1199:         }
1200:     }
1201: 
1202:     /**
1203:      * This function performs the validation work for complex object models.
1204:      *
1205:      * In addition to checking the current object, all related objects will
1206:      * also be validated.  If all pass then <code>true</code> is returned; otherwise
1207:      * an aggreagated array of ValidationFailed objects will be returned.
1208:      *
1209:      * @param array $columns Array of column names to validate.
1210:      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
1211:      */
1212:     protected function doValidate($columns = null)
1213:     {
1214:         if (!$this->alreadyInValidation) {
1215:             $this->alreadyInValidation = true;
1216:             $retval = null;
1217: 
1218:             $failureMap = array();
1219: 
1220: 
1221:             if (($retval = FolderPeer::doValidate($this, $columns)) !== true) {
1222:                 $failureMap = array_merge($failureMap, $retval);
1223:             }
1224: 
1225: 
1226:                 if ($this->collImages !== null) {
1227:                     foreach ($this->collImages as $referrerFK) {
1228:                         if (!$referrerFK->validate($columns)) {
1229:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1230:                         }
1231:                     }
1232:                 }
1233: 
1234:                 if ($this->collDocuments !== null) {
1235:                     foreach ($this->collDocuments as $referrerFK) {
1236:                         if (!$referrerFK->validate($columns)) {
1237:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1238:                         }
1239:                     }
1240:                 }
1241: 
1242:                 if ($this->collRewritings !== null) {
1243:                     foreach ($this->collRewritings as $referrerFK) {
1244:                         if (!$referrerFK->validate($columns)) {
1245:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1246:                         }
1247:                     }
1248:                 }
1249: 
1250:                 if ($this->collContentFolders !== null) {
1251:                     foreach ($this->collContentFolders as $referrerFK) {
1252:                         if (!$referrerFK->validate($columns)) {
1253:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1254:                         }
1255:                     }
1256:                 }
1257: 
1258:                 if ($this->collFolderI18ns !== null) {
1259:                     foreach ($this->collFolderI18ns as $referrerFK) {
1260:                         if (!$referrerFK->validate($columns)) {
1261:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1262:                         }
1263:                     }
1264:                 }
1265: 
1266:                 if ($this->collFolderVersions !== null) {
1267:                     foreach ($this->collFolderVersions as $referrerFK) {
1268:                         if (!$referrerFK->validate($columns)) {
1269:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1270:                         }
1271:                     }
1272:                 }
1273: 
1274: 
1275:             $this->alreadyInValidation = false;
1276:         }
1277: 
1278:         return (!empty($failureMap) ? $failureMap : true);
1279:     }
1280: 
1281:     /**
1282:      * Retrieves a field from the object by name passed in as a string.
1283:      *
1284:      * @param string $name name
1285:      * @param string $type The type of fieldname the $name is of:
1286:      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
1287:      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1288:      *               Defaults to BasePeer::TYPE_PHPNAME
1289:      * @return mixed Value of field.
1290:      */
1291:     public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
1292:     {
1293:         $pos = FolderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1294:         $field = $this->getByPosition($pos);
1295: 
1296:         return $field;
1297:     }
1298: 
1299:     /**
1300:      * Retrieves a field from the object by Position as specified in the xml schema.
1301:      * Zero-based.
1302:      *
1303:      * @param int $pos position in xml schema
1304:      * @return mixed Value of field at $pos
1305:      */
1306:     public function getByPosition($pos)
1307:     {
1308:         switch ($pos) {
1309:             case 0:
1310:                 return $this->getId();
1311:                 break;
1312:             case 1:
1313:                 return $this->getParent();
1314:                 break;
1315:             case 2:
1316:                 return $this->getLink();
1317:                 break;
1318:             case 3:
1319:                 return $this->getVisible();
1320:                 break;
1321:             case 4:
1322:                 return $this->getPosition();
1323:                 break;
1324:             case 5:
1325:                 return $this->getCreatedAt();
1326:                 break;
1327:             case 6:
1328:                 return $this->getUpdatedAt();
1329:                 break;
1330:             case 7:
1331:                 return $this->getVersion();
1332:                 break;
1333:             case 8:
1334:                 return $this->getVersionCreatedAt();
1335:                 break;
1336:             case 9:
1337:                 return $this->getVersionCreatedBy();
1338:                 break;
1339:             default:
1340:                 return null;
1341:                 break;
1342:         } // switch()
1343:     }
1344: 
1345:     /**
1346:      * Exports the object as an array.
1347:      *
1348:      * You can specify the key type of the array by passing one of the class
1349:      * type constants.
1350:      *
1351:      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1352:      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1353:      *                    Defaults to BasePeer::TYPE_PHPNAME.
1354:      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
1355:      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
1356:      * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
1357:      *
1358:      * @return array an associative array containing the field names (as keys) and field values
1359:      */
1360:     public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
1361:     {
1362:         if (isset($alreadyDumpedObjects['Folder'][$this->getPrimaryKey()])) {
1363:             return '*RECURSION*';
1364:         }
1365:         $alreadyDumpedObjects['Folder'][$this->getPrimaryKey()] = true;
1366:         $keys = FolderPeer::getFieldNames($keyType);
1367:         $result = array(
1368:             $keys[0] => $this->getId(),
1369:             $keys[1] => $this->getParent(),
1370:             $keys[2] => $this->getLink(),
1371:             $keys[3] => $this->getVisible(),
1372:             $keys[4] => $this->getPosition(),
1373:             $keys[5] => $this->getCreatedAt(),
1374:             $keys[6] => $this->getUpdatedAt(),
1375:             $keys[7] => $this->getVersion(),
1376:             $keys[8] => $this->getVersionCreatedAt(),
1377:             $keys[9] => $this->getVersionCreatedBy(),
1378:         );
1379:         if ($includeForeignObjects) {
1380:             if (null !== $this->collImages) {
1381:                 $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1382:             }
1383:             if (null !== $this->collDocuments) {
1384:                 $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1385:             }
1386:             if (null !== $this->collRewritings) {
1387:                 $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1388:             }
1389:             if (null !== $this->collContentFolders) {
1390:                 $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1391:             }
1392:             if (null !== $this->collFolderI18ns) {
1393:                 $result['FolderI18ns'] = $this->collFolderI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1394:             }
1395:             if (null !== $this->collFolderVersions) {
1396:                 $result['FolderVersions'] = $this->collFolderVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1397:             }
1398:         }
1399: 
1400:         return $result;
1401:     }
1402: 
1403:     /**
1404:      * Sets a field from the object by name passed in as a string.
1405:      *
1406:      * @param string $name peer name
1407:      * @param mixed $value field value
1408:      * @param string $type The type of fieldname the $name is of:
1409:      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
1410:      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1411:      *                     Defaults to BasePeer::TYPE_PHPNAME
1412:      * @return void
1413:      */
1414:     public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
1415:     {
1416:         $pos = FolderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1417: 
1418:         $this->setByPosition($pos, $value);
1419:     }
1420: 
1421:     /**
1422:      * Sets a field from the object by Position as specified in the xml schema.
1423:      * Zero-based.
1424:      *
1425:      * @param int $pos position in xml schema
1426:      * @param mixed $value field value
1427:      * @return void
1428:      */
1429:     public function setByPosition($pos, $value)
1430:     {
1431:         switch ($pos) {
1432:             case 0:
1433:                 $this->setId($value);
1434:                 break;
1435:             case 1:
1436:                 $this->setParent($value);
1437:                 break;
1438:             case 2:
1439:                 $this->setLink($value);
1440:                 break;
1441:             case 3:
1442:                 $this->setVisible($value);
1443:                 break;
1444:             case 4:
1445:                 $this->setPosition($value);
1446:                 break;
1447:             case 5:
1448:                 $this->setCreatedAt($value);
1449:                 break;
1450:             case 6:
1451:                 $this->setUpdatedAt($value);
1452:                 break;
1453:             case 7:
1454:                 $this->setVersion($value);
1455:                 break;
1456:             case 8:
1457:                 $this->setVersionCreatedAt($value);
1458:                 break;
1459:             case 9:
1460:                 $this->setVersionCreatedBy($value);
1461:                 break;
1462:         } // switch()
1463:     }
1464: 
1465:     /**
1466:      * Populates the object using an array.
1467:      *
1468:      * This is particularly useful when populating an object from one of the
1469:      * request arrays (e.g. $_POST).  This method goes through the column
1470:      * names, checking to see whether a matching key exists in populated
1471:      * array. If so the setByName() method is called for that column.
1472:      *
1473:      * You can specify the key type of the array by additionally passing one
1474:      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1475:      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1476:      * The default key type is the column's BasePeer::TYPE_PHPNAME
1477:      *
1478:      * @param array  $arr     An array to populate the object from.
1479:      * @param string $keyType The type of keys the array uses.
1480:      * @return void
1481:      */
1482:     public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
1483:     {
1484:         $keys = FolderPeer::getFieldNames($keyType);
1485: 
1486:         if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
1487:         if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]);
1488:         if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]);
1489:         if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]);
1490:         if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
1491:         if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
1492:         if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
1493:         if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]);
1494:         if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]);
1495:         if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]);
1496:     }
1497: 
1498:     /**
1499:      * Build a Criteria object containing the values of all modified columns in this object.
1500:      *
1501:      * @return Criteria The Criteria object containing all modified values.
1502:      */
1503:     public function buildCriteria()
1504:     {
1505:         $criteria = new Criteria(FolderPeer::DATABASE_NAME);
1506: 
1507:         if ($this->isColumnModified(FolderPeer::ID)) $criteria->add(FolderPeer::ID, $this->id);
1508:         if ($this->isColumnModified(FolderPeer::PARENT)) $criteria->add(FolderPeer::PARENT, $this->parent);
1509:         if ($this->isColumnModified(FolderPeer::LINK)) $criteria->add(FolderPeer::LINK, $this->link);
1510:         if ($this->isColumnModified(FolderPeer::VISIBLE)) $criteria->add(FolderPeer::VISIBLE, $this->visible);
1511:         if ($this->isColumnModified(FolderPeer::POSITION)) $criteria->add(FolderPeer::POSITION, $this->position);
1512:         if ($this->isColumnModified(FolderPeer::CREATED_AT)) $criteria->add(FolderPeer::CREATED_AT, $this->created_at);
1513:         if ($this->isColumnModified(FolderPeer::UPDATED_AT)) $criteria->add(FolderPeer::UPDATED_AT, $this->updated_at);
1514:         if ($this->isColumnModified(FolderPeer::VERSION)) $criteria->add(FolderPeer::VERSION, $this->version);
1515:         if ($this->isColumnModified(FolderPeer::VERSION_CREATED_AT)) $criteria->add(FolderPeer::VERSION_CREATED_AT, $this->version_created_at);
1516:         if ($this->isColumnModified(FolderPeer::VERSION_CREATED_BY)) $criteria->add(FolderPeer::VERSION_CREATED_BY, $this->version_created_by);
1517: 
1518:         return $criteria;
1519:     }
1520: 
1521:     /**
1522:      * Builds a Criteria object containing the primary key for this object.
1523:      *
1524:      * Unlike buildCriteria() this method includes the primary key values regardless
1525:      * of whether or not they have been modified.
1526:      *
1527:      * @return Criteria The Criteria object containing value(s) for primary key(s).
1528:      */
1529:     public function buildPkeyCriteria()
1530:     {
1531:         $criteria = new Criteria(FolderPeer::DATABASE_NAME);
1532:         $criteria->add(FolderPeer::ID, $this->id);
1533: 
1534:         return $criteria;
1535:     }
1536: 
1537:     /**
1538:      * Returns the primary key for this object (row).
1539:      * @return int
1540:      */
1541:     public function getPrimaryKey()
1542:     {
1543:         return $this->getId();
1544:     }
1545: 
1546:     /**
1547:      * Generic method to set the primary key (id column).
1548:      *
1549:      * @param  int $key Primary key.
1550:      * @return void
1551:      */
1552:     public function setPrimaryKey($key)
1553:     {
1554:         $this->setId($key);
1555:     }
1556: 
1557:     /**
1558:      * Returns true if the primary key for this object is null.
1559:      * @return boolean
1560:      */
1561:     public function isPrimaryKeyNull()
1562:     {
1563: 
1564:         return null === $this->getId();
1565:     }
1566: 
1567:     /**
1568:      * Sets contents of passed object to values from current object.
1569:      *
1570:      * If desired, this method can also make copies of all associated (fkey referrers)
1571:      * objects.
1572:      *
1573:      * @param object $copyObj An object of Folder (or compatible) type.
1574:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1575:      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1576:      * @throws PropelException
1577:      */
1578:     public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1579:     {
1580:         $copyObj->setParent($this->getParent());
1581:         $copyObj->setLink($this->getLink());
1582:         $copyObj->setVisible($this->getVisible());
1583:         $copyObj->setPosition($this->getPosition());
1584:         $copyObj->setCreatedAt($this->getCreatedAt());
1585:         $copyObj->setUpdatedAt($this->getUpdatedAt());
1586:         $copyObj->setVersion($this->getVersion());
1587:         $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
1588:         $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
1589: 
1590:         if ($deepCopy && !$this->startCopy) {
1591:             // important: temporarily setNew(false) because this affects the behavior of
1592:             // the getter/setter methods for fkey referrer objects.
1593:             $copyObj->setNew(false);
1594:             // store object hash to prevent cycle
1595:             $this->startCopy = true;
1596: 
1597:             foreach ($this->getImages() as $relObj) {
1598:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1599:                     $copyObj->addImage($relObj->copy($deepCopy));
1600:                 }
1601:             }
1602: 
1603:             foreach ($this->getDocuments() as $relObj) {
1604:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1605:                     $copyObj->addDocument($relObj->copy($deepCopy));
1606:                 }
1607:             }
1608: 
1609:             foreach ($this->getRewritings() as $relObj) {
1610:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1611:                     $copyObj->addRewriting($relObj->copy($deepCopy));
1612:                 }
1613:             }
1614: 
1615:             foreach ($this->getContentFolders() as $relObj) {
1616:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1617:                     $copyObj->addContentFolder($relObj->copy($deepCopy));
1618:                 }
1619:             }
1620: 
1621:             foreach ($this->getFolderI18ns() as $relObj) {
1622:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1623:                     $copyObj->addFolderI18n($relObj->copy($deepCopy));
1624:                 }
1625:             }
1626: 
1627:             foreach ($this->getFolderVersions() as $relObj) {
1628:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1629:                     $copyObj->addFolderVersion($relObj->copy($deepCopy));
1630:                 }
1631:             }
1632: 
1633:             //unflag object copy
1634:             $this->startCopy = false;
1635:         } // if ($deepCopy)
1636: 
1637:         if ($makeNew) {
1638:             $copyObj->setNew(true);
1639:             $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
1640:         }
1641:     }
1642: 
1643:     /**
1644:      * Makes a copy of this object that will be inserted as a new row in table when saved.
1645:      * It creates a new object filling in the simple attributes, but skipping any primary
1646:      * keys that are defined for the table.
1647:      *
1648:      * If desired, this method can also make copies of all associated (fkey referrers)
1649:      * objects.
1650:      *
1651:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1652:      * @return Folder Clone of current object.
1653:      * @throws PropelException
1654:      */
1655:     public function copy($deepCopy = false)
1656:     {
1657:         // we use get_class(), because this might be a subclass
1658:         $clazz = get_class($this);
1659:         $copyObj = new $clazz();
1660:         $this->copyInto($copyObj, $deepCopy);
1661: 
1662:         return $copyObj;
1663:     }
1664: 
1665:     /**
1666:      * Returns a peer instance associated with this om.
1667:      *
1668:      * Since Peer classes are not to have any instance attributes, this method returns the
1669:      * same instance for all member of this class. The method could therefore
1670:      * be static, but this would prevent one from overriding the behavior.
1671:      *
1672:      * @return FolderPeer
1673:      */
1674:     public function getPeer()
1675:     {
1676:         if (self::$peer === null) {
1677:             self::$peer = new FolderPeer();
1678:         }
1679: 
1680:         return self::$peer;
1681:     }
1682: 
1683: 
1684:     /**
1685:      * Initializes a collection based on the name of a relation.
1686:      * Avoids crafting an 'init[$relationName]s' method name
1687:      * that wouldn't work when StandardEnglishPluralizer is used.
1688:      *
1689:      * @param string $relationName The name of the relation to initialize
1690:      * @return void
1691:      */
1692:     public function initRelation($relationName)
1693:     {
1694:         if ('Image' == $relationName) {
1695:             $this->initImages();
1696:         }
1697:         if ('Document' == $relationName) {
1698:             $this->initDocuments();
1699:         }
1700:         if ('Rewriting' == $relationName) {
1701:             $this->initRewritings();
1702:         }
1703:         if ('ContentFolder' == $relationName) {
1704:             $this->initContentFolders();
1705:         }
1706:         if ('FolderI18n' == $relationName) {
1707:             $this->initFolderI18ns();
1708:         }
1709:         if ('FolderVersion' == $relationName) {
1710:             $this->initFolderVersions();
1711:         }
1712:     }
1713: 
1714:     /**
1715:      * Clears out the collImages collection
1716:      *
1717:      * This does not modify the database; however, it will remove any associated objects, causing
1718:      * them to be refetched by subsequent calls to accessor method.
1719:      *
1720:      * @return void
1721:      * @see        addImages()
1722:      */
1723:     public function clearImages()
1724:     {
1725:         $this->collImages = null; // important to set this to null since that means it is uninitialized
1726:         $this->collImagesPartial = null;
1727:     }
1728: 
1729:     /**
1730:      * reset is the collImages collection loaded partially
1731:      *
1732:      * @return void
1733:      */
1734:     public function resetPartialImages($v = true)
1735:     {
1736:         $this->collImagesPartial = $v;
1737:     }
1738: 
1739:     /**
1740:      * Initializes the collImages collection.
1741:      *
1742:      * By default this just sets the collImages collection to an empty array (like clearcollImages());
1743:      * however, you may wish to override this method in your stub class to provide setting appropriate
1744:      * to your application -- for example, setting the initial array to the values stored in database.
1745:      *
1746:      * @param boolean $overrideExisting If set to true, the method call initializes
1747:      *                                        the collection even if it is not empty
1748:      *
1749:      * @return void
1750:      */
1751:     public function initImages($overrideExisting = true)
1752:     {
1753:         if (null !== $this->collImages && !$overrideExisting) {
1754:             return;
1755:         }
1756:         $this->collImages = new PropelObjectCollection();
1757:         $this->collImages->setModel('Image');
1758:     }
1759: 
1760:     /**
1761:      * Gets an array of Image objects which contain a foreign key that references this object.
1762:      *
1763:      * If the $criteria is not null, it is used to always fetch the results from the database.
1764:      * Otherwise the results are fetched from the database the first time, then cached.
1765:      * Next time the same method is called without $criteria, the cached collection is returned.
1766:      * If this Folder is new, it will return
1767:      * an empty collection or the current collection; the criteria is ignored on a new object.
1768:      *
1769:      * @param Criteria $criteria optional Criteria object to narrow the query
1770:      * @param PropelPDO $con optional connection object
1771:      * @return PropelObjectCollection|Image[] List of Image objects
1772:      * @throws PropelException
1773:      */
1774:     public function getImages($criteria = null, PropelPDO $con = null)
1775:     {
1776:         $partial = $this->collImagesPartial && !$this->isNew();
1777:         if (null === $this->collImages || null !== $criteria  || $partial) {
1778:             if ($this->isNew() && null === $this->collImages) {
1779:                 // return empty collection
1780:                 $this->initImages();
1781:             } else {
1782:                 $collImages = ImageQuery::create(null, $criteria)
1783:                     ->filterByFolder($this)
1784:                     ->find($con);
1785:                 if (null !== $criteria) {
1786:                     if (false !== $this->collImagesPartial && count($collImages)) {
1787:                       $this->initImages(false);
1788: 
1789:                       foreach($collImages as $obj) {
1790:                         if (false == $this->collImages->contains($obj)) {
1791:                           $this->collImages->append($obj);
1792:                         }
1793:                       }
1794: 
1795:                       $this->collImagesPartial = true;
1796:                     }
1797: 
1798:                     return $collImages;
1799:                 }
1800: 
1801:                 if($partial && $this->collImages) {
1802:                     foreach($this->collImages as $obj) {
1803:                         if($obj->isNew()) {
1804:                             $collImages[] = $obj;
1805:                         }
1806:                     }
1807:                 }
1808: 
1809:                 $this->collImages = $collImages;
1810:                 $this->collImagesPartial = false;
1811:             }
1812:         }
1813: 
1814:         return $this->collImages;
1815:     }
1816: 
1817:     /**
1818:      * Sets a collection of Image objects related by a one-to-many relationship
1819:      * to the current object.
1820:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1821:      * and new objects from the given Propel collection.
1822:      *
1823:      * @param PropelCollection $images A Propel collection.
1824:      * @param PropelPDO $con Optional connection object
1825:      */
1826:     public function setImages(PropelCollection $images, PropelPDO $con = null)
1827:     {
1828:         $this->imagesScheduledForDeletion = $this->getImages(new Criteria(), $con)->diff($images);
1829: 
1830:         foreach ($this->imagesScheduledForDeletion as $imageRemoved) {
1831:             $imageRemoved->setFolder(null);
1832:         }
1833: 
1834:         $this->collImages = null;
1835:         foreach ($images as $image) {
1836:             $this->addImage($image);
1837:         }
1838: 
1839:         $this->collImages = $images;
1840:         $this->collImagesPartial = false;
1841:     }
1842: 
1843:     /**
1844:      * Returns the number of related Image objects.
1845:      *
1846:      * @param Criteria $criteria
1847:      * @param boolean $distinct
1848:      * @param PropelPDO $con
1849:      * @return int             Count of related Image objects.
1850:      * @throws PropelException
1851:      */
1852:     public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1853:     {
1854:         $partial = $this->collImagesPartial && !$this->isNew();
1855:         if (null === $this->collImages || null !== $criteria || $partial) {
1856:             if ($this->isNew() && null === $this->collImages) {
1857:                 return 0;
1858:             } else {
1859:                 if($partial && !$criteria) {
1860:                     return count($this->getImages());
1861:                 }
1862:                 $query = ImageQuery::create(null, $criteria);
1863:                 if ($distinct) {
1864:                     $query->distinct();
1865:                 }
1866: 
1867:                 return $query
1868:                     ->filterByFolder($this)
1869:                     ->count($con);
1870:             }
1871:         } else {
1872:             return count($this->collImages);
1873:         }
1874:     }
1875: 
1876:     /**
1877:      * Method called to associate a Image object to this object
1878:      * through the Image foreign key attribute.
1879:      *
1880:      * @param    Image $l Image
1881:      * @return Folder The current object (for fluent API support)
1882:      */
1883:     public function addImage(Image $l)
1884:     {
1885:         if ($this->collImages === null) {
1886:             $this->initImages();
1887:             $this->collImagesPartial = true;
1888:         }
1889:         if (!$this->collImages->contains($l)) { // only add it if the **same** object is not already associated
1890:             $this->doAddImage($l);
1891:         }
1892: 
1893:         return $this;
1894:     }
1895: 
1896:     /**
1897:      * @param   Image $image The image object to add.
1898:      */
1899:     protected function doAddImage($image)
1900:     {
1901:         $this->collImages[]= $image;
1902:         $image->setFolder($this);
1903:     }
1904: 
1905:     /**
1906:      * @param   Image $image The image object to remove.
1907:      */
1908:     public function removeImage($image)
1909:     {
1910:         if ($this->getImages()->contains($image)) {
1911:             $this->collImages->remove($this->collImages->search($image));
1912:             if (null === $this->imagesScheduledForDeletion) {
1913:                 $this->imagesScheduledForDeletion = clone $this->collImages;
1914:                 $this->imagesScheduledForDeletion->clear();
1915:             }
1916:             $this->imagesScheduledForDeletion[]= $image;
1917:             $image->setFolder(null);
1918:         }
1919:     }
1920: 
1921: 
1922:     /**
1923:      * If this collection has already been initialized with
1924:      * an identical criteria, it returns the collection.
1925:      * Otherwise if this Folder is new, it will return
1926:      * an empty collection; or if this Folder has previously
1927:      * been saved, it will retrieve related Images from storage.
1928:      *
1929:      * This method is protected by default in order to keep the public
1930:      * api reasonable.  You can provide public methods for those you
1931:      * actually need in Folder.
1932:      *
1933:      * @param Criteria $criteria optional Criteria object to narrow the query
1934:      * @param PropelPDO $con optional connection object
1935:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1936:      * @return PropelObjectCollection|Image[] List of Image objects
1937:      */
1938:     public function getImagesJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1939:     {
1940:         $query = ImageQuery::create(null, $criteria);
1941:         $query->joinWith('Product', $join_behavior);
1942: 
1943:         return $this->getImages($query, $con);
1944:     }
1945: 
1946: 
1947:     /**
1948:      * If this collection has already been initialized with
1949:      * an identical criteria, it returns the collection.
1950:      * Otherwise if this Folder is new, it will return
1951:      * an empty collection; or if this Folder has previously
1952:      * been saved, it will retrieve related Images from storage.
1953:      *
1954:      * This method is protected by default in order to keep the public
1955:      * api reasonable.  You can provide public methods for those you
1956:      * actually need in Folder.
1957:      *
1958:      * @param Criteria $criteria optional Criteria object to narrow the query
1959:      * @param PropelPDO $con optional connection object
1960:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1961:      * @return PropelObjectCollection|Image[] List of Image objects
1962:      */
1963:     public function getImagesJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1964:     {
1965:         $query = ImageQuery::create(null, $criteria);
1966:         $query->joinWith('Category', $join_behavior);
1967: 
1968:         return $this->getImages($query, $con);
1969:     }
1970: 
1971: 
1972:     /**
1973:      * If this collection has already been initialized with
1974:      * an identical criteria, it returns the collection.
1975:      * Otherwise if this Folder is new, it will return
1976:      * an empty collection; or if this Folder has previously
1977:      * been saved, it will retrieve related Images from storage.
1978:      *
1979:      * This method is protected by default in order to keep the public
1980:      * api reasonable.  You can provide public methods for those you
1981:      * actually need in Folder.
1982:      *
1983:      * @param Criteria $criteria optional Criteria object to narrow the query
1984:      * @param PropelPDO $con optional connection object
1985:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1986:      * @return PropelObjectCollection|Image[] List of Image objects
1987:      */
1988:     public function getImagesJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1989:     {
1990:         $query = ImageQuery::create(null, $criteria);
1991:         $query->joinWith('Content', $join_behavior);
1992: 
1993:         return $this->getImages($query, $con);
1994:     }
1995: 
1996:     /**
1997:      * Clears out the collDocuments collection
1998:      *
1999:      * This does not modify the database; however, it will remove any associated objects, causing
2000:      * them to be refetched by subsequent calls to accessor method.
2001:      *
2002:      * @return void
2003:      * @see        addDocuments()
2004:      */
2005:     public function clearDocuments()
2006:     {
2007:         $this->collDocuments = null; // important to set this to null since that means it is uninitialized
2008:         $this->collDocumentsPartial = null;
2009:     }
2010: 
2011:     /**
2012:      * reset is the collDocuments collection loaded partially
2013:      *
2014:      * @return void
2015:      */
2016:     public function resetPartialDocuments($v = true)
2017:     {
2018:         $this->collDocumentsPartial = $v;
2019:     }
2020: 
2021:     /**
2022:      * Initializes the collDocuments collection.
2023:      *
2024:      * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments());
2025:      * however, you may wish to override this method in your stub class to provide setting appropriate
2026:      * to your application -- for example, setting the initial array to the values stored in database.
2027:      *
2028:      * @param boolean $overrideExisting If set to true, the method call initializes
2029:      *                                        the collection even if it is not empty
2030:      *
2031:      * @return void
2032:      */
2033:     public function initDocuments($overrideExisting = true)
2034:     {
2035:         if (null !== $this->collDocuments && !$overrideExisting) {
2036:             return;
2037:         }
2038:         $this->collDocuments = new PropelObjectCollection();
2039:         $this->collDocuments->setModel('Document');
2040:     }
2041: 
2042:     /**
2043:      * Gets an array of Document objects which contain a foreign key that references this object.
2044:      *
2045:      * If the $criteria is not null, it is used to always fetch the results from the database.
2046:      * Otherwise the results are fetched from the database the first time, then cached.
2047:      * Next time the same method is called without $criteria, the cached collection is returned.
2048:      * If this Folder is new, it will return
2049:      * an empty collection or the current collection; the criteria is ignored on a new object.
2050:      *
2051:      * @param Criteria $criteria optional Criteria object to narrow the query
2052:      * @param PropelPDO $con optional connection object
2053:      * @return PropelObjectCollection|Document[] List of Document objects
2054:      * @throws PropelException
2055:      */
2056:     public function getDocuments($criteria = null, PropelPDO $con = null)
2057:     {
2058:         $partial = $this->collDocumentsPartial && !$this->isNew();
2059:         if (null === $this->collDocuments || null !== $criteria  || $partial) {
2060:             if ($this->isNew() && null === $this->collDocuments) {
2061:                 // return empty collection
2062:                 $this->initDocuments();
2063:             } else {
2064:                 $collDocuments = DocumentQuery::create(null, $criteria)
2065:                     ->filterByFolder($this)
2066:                     ->find($con);
2067:                 if (null !== $criteria) {
2068:                     if (false !== $this->collDocumentsPartial && count($collDocuments)) {
2069:                       $this->initDocuments(false);
2070: 
2071:                       foreach($collDocuments as $obj) {
2072:                         if (false == $this->collDocuments->contains($obj)) {
2073:                           $this->collDocuments->append($obj);
2074:                         }
2075:                       }
2076: 
2077:                       $this->collDocumentsPartial = true;
2078:                     }
2079: 
2080:                     return $collDocuments;
2081:                 }
2082: 
2083:                 if($partial && $this->collDocuments) {
2084:                     foreach($this->collDocuments as $obj) {
2085:                         if($obj->isNew()) {
2086:                             $collDocuments[] = $obj;
2087:                         }
2088:                     }
2089:                 }
2090: 
2091:                 $this->collDocuments = $collDocuments;
2092:                 $this->collDocumentsPartial = false;
2093:             }
2094:         }
2095: 
2096:         return $this->collDocuments;
2097:     }
2098: 
2099:     /**
2100:      * Sets a collection of Document objects related by a one-to-many relationship
2101:      * to the current object.
2102:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2103:      * and new objects from the given Propel collection.
2104:      *
2105:      * @param PropelCollection $documents A Propel collection.
2106:      * @param PropelPDO $con Optional connection object
2107:      */
2108:     public function setDocuments(PropelCollection $documents, PropelPDO $con = null)
2109:     {
2110:         $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents);
2111: 
2112:         foreach ($this->documentsScheduledForDeletion as $documentRemoved) {
2113:             $documentRemoved->setFolder(null);
2114:         }
2115: 
2116:         $this->collDocuments = null;
2117:         foreach ($documents as $document) {
2118:             $this->addDocument($document);
2119:         }
2120: 
2121:         $this->collDocuments = $documents;
2122:         $this->collDocumentsPartial = false;
2123:     }
2124: 
2125:     /**
2126:      * Returns the number of related Document objects.
2127:      *
2128:      * @param Criteria $criteria
2129:      * @param boolean $distinct
2130:      * @param PropelPDO $con
2131:      * @return int             Count of related Document objects.
2132:      * @throws PropelException
2133:      */
2134:     public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2135:     {
2136:         $partial = $this->collDocumentsPartial && !$this->isNew();
2137:         if (null === $this->collDocuments || null !== $criteria || $partial) {
2138:             if ($this->isNew() && null === $this->collDocuments) {
2139:                 return 0;
2140:             } else {
2141:                 if($partial && !$criteria) {
2142:                     return count($this->getDocuments());
2143:                 }
2144:                 $query = DocumentQuery::create(null, $criteria);
2145:                 if ($distinct) {
2146:                     $query->distinct();
2147:                 }
2148: 
2149:                 return $query
2150:                     ->filterByFolder($this)
2151:                     ->count($con);
2152:             }
2153:         } else {
2154:             return count($this->collDocuments);
2155:         }
2156:     }
2157: 
2158:     /**
2159:      * Method called to associate a Document object to this object
2160:      * through the Document foreign key attribute.
2161:      *
2162:      * @param    Document $l Document
2163:      * @return Folder The current object (for fluent API support)
2164:      */
2165:     public function addDocument(Document $l)
2166:     {
2167:         if ($this->collDocuments === null) {
2168:             $this->initDocuments();
2169:             $this->collDocumentsPartial = true;
2170:         }
2171:         if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated
2172:             $this->doAddDocument($l);
2173:         }
2174: 
2175:         return $this;
2176:     }
2177: 
2178:     /**
2179:      * @param   Document $document The document object to add.
2180:      */
2181:     protected function doAddDocument($document)
2182:     {
2183:         $this->collDocuments[]= $document;
2184:         $document->setFolder($this);
2185:     }
2186: 
2187:     /**
2188:      * @param   Document $document The document object to remove.
2189:      */
2190:     public function removeDocument($document)
2191:     {
2192:         if ($this->getDocuments()->contains($document)) {
2193:             $this->collDocuments->remove($this->collDocuments->search($document));
2194:             if (null === $this->documentsScheduledForDeletion) {
2195:                 $this->documentsScheduledForDeletion = clone $this->collDocuments;
2196:                 $this->documentsScheduledForDeletion->clear();
2197:             }
2198:             $this->documentsScheduledForDeletion[]= $document;
2199:             $document->setFolder(null);
2200:         }
2201:     }
2202: 
2203: 
2204:     /**
2205:      * If this collection has already been initialized with
2206:      * an identical criteria, it returns the collection.
2207:      * Otherwise if this Folder is new, it will return
2208:      * an empty collection; or if this Folder has previously
2209:      * been saved, it will retrieve related Documents from storage.
2210:      *
2211:      * This method is protected by default in order to keep the public
2212:      * api reasonable.  You can provide public methods for those you
2213:      * actually need in Folder.
2214:      *
2215:      * @param Criteria $criteria optional Criteria object to narrow the query
2216:      * @param PropelPDO $con optional connection object
2217:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2218:      * @return PropelObjectCollection|Document[] List of Document objects
2219:      */
2220:     public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2221:     {
2222:         $query = DocumentQuery::create(null, $criteria);
2223:         $query->joinWith('Product', $join_behavior);
2224: 
2225:         return $this->getDocuments($query, $con);
2226:     }
2227: 
2228: 
2229:     /**
2230:      * If this collection has already been initialized with
2231:      * an identical criteria, it returns the collection.
2232:      * Otherwise if this Folder is new, it will return
2233:      * an empty collection; or if this Folder has previously
2234:      * been saved, it will retrieve related Documents from storage.
2235:      *
2236:      * This method is protected by default in order to keep the public
2237:      * api reasonable.  You can provide public methods for those you
2238:      * actually need in Folder.
2239:      *
2240:      * @param Criteria $criteria optional Criteria object to narrow the query
2241:      * @param PropelPDO $con optional connection object
2242:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2243:      * @return PropelObjectCollection|Document[] List of Document objects
2244:      */
2245:     public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2246:     {
2247:         $query = DocumentQuery::create(null, $criteria);
2248:         $query->joinWith('Category', $join_behavior);
2249: 
2250:         return $this->getDocuments($query, $con);
2251:     }
2252: 
2253: 
2254:     /**
2255:      * If this collection has already been initialized with
2256:      * an identical criteria, it returns the collection.
2257:      * Otherwise if this Folder is new, it will return
2258:      * an empty collection; or if this Folder has previously
2259:      * been saved, it will retrieve related Documents from storage.
2260:      *
2261:      * This method is protected by default in order to keep the public
2262:      * api reasonable.  You can provide public methods for those you
2263:      * actually need in Folder.
2264:      *
2265:      * @param Criteria $criteria optional Criteria object to narrow the query
2266:      * @param PropelPDO $con optional connection object
2267:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2268:      * @return PropelObjectCollection|Document[] List of Document objects
2269:      */
2270:     public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2271:     {
2272:         $query = DocumentQuery::create(null, $criteria);
2273:         $query->joinWith('Content', $join_behavior);
2274: 
2275:         return $this->getDocuments($query, $con);
2276:     }
2277: 
2278:     /**
2279:      * Clears out the collRewritings collection
2280:      *
2281:      * This does not modify the database; however, it will remove any associated objects, causing
2282:      * them to be refetched by subsequent calls to accessor method.
2283:      *
2284:      * @return void
2285:      * @see        addRewritings()
2286:      */
2287:     public function clearRewritings()
2288:     {
2289:         $this->collRewritings = null; // important to set this to null since that means it is uninitialized
2290:         $this->collRewritingsPartial = null;
2291:     }
2292: 
2293:     /**
2294:      * reset is the collRewritings collection loaded partially
2295:      *
2296:      * @return void
2297:      */
2298:     public function resetPartialRewritings($v = true)
2299:     {
2300:         $this->collRewritingsPartial = $v;
2301:     }
2302: 
2303:     /**
2304:      * Initializes the collRewritings collection.
2305:      *
2306:      * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings());
2307:      * however, you may wish to override this method in your stub class to provide setting appropriate
2308:      * to your application -- for example, setting the initial array to the values stored in database.
2309:      *
2310:      * @param boolean $overrideExisting If set to true, the method call initializes
2311:      *                                        the collection even if it is not empty
2312:      *
2313:      * @return void
2314:      */
2315:     public function initRewritings($overrideExisting = true)
2316:     {
2317:         if (null !== $this->collRewritings && !$overrideExisting) {
2318:             return;
2319:         }
2320:         $this->collRewritings = new PropelObjectCollection();
2321:         $this->collRewritings->setModel('Rewriting');
2322:     }
2323: 
2324:     /**
2325:      * Gets an array of Rewriting objects which contain a foreign key that references this object.
2326:      *
2327:      * If the $criteria is not null, it is used to always fetch the results from the database.
2328:      * Otherwise the results are fetched from the database the first time, then cached.
2329:      * Next time the same method is called without $criteria, the cached collection is returned.
2330:      * If this Folder is new, it will return
2331:      * an empty collection or the current collection; the criteria is ignored on a new object.
2332:      *
2333:      * @param Criteria $criteria optional Criteria object to narrow the query
2334:      * @param PropelPDO $con optional connection object
2335:      * @return PropelObjectCollection|Rewriting[] List of Rewriting objects
2336:      * @throws PropelException
2337:      */
2338:     public function getRewritings($criteria = null, PropelPDO $con = null)
2339:     {
2340:         $partial = $this->collRewritingsPartial && !$this->isNew();
2341:         if (null === $this->collRewritings || null !== $criteria  || $partial) {
2342:             if ($this->isNew() && null === $this->collRewritings) {
2343:                 // return empty collection
2344:                 $this->initRewritings();
2345:             } else {
2346:                 $collRewritings = RewritingQuery::create(null, $criteria)
2347:                     ->filterByFolder($this)
2348:                     ->find($con);
2349:                 if (null !== $criteria) {
2350:                     if (false !== $this->collRewritingsPartial && count($collRewritings)) {
2351:                       $this->initRewritings(false);
2352: 
2353:                       foreach($collRewritings as $obj) {
2354:                         if (false == $this->collRewritings->contains($obj)) {
2355:                           $this->collRewritings->append($obj);
2356:                         }
2357:                       }
2358: 
2359:                       $this->collRewritingsPartial = true;
2360:                     }
2361: 
2362:                     return $collRewritings;
2363:                 }
2364: 
2365:                 if($partial && $this->collRewritings) {
2366:                     foreach($this->collRewritings as $obj) {
2367:                         if($obj->isNew()) {
2368:                             $collRewritings[] = $obj;
2369:                         }
2370:                     }
2371:                 }
2372: 
2373:                 $this->collRewritings = $collRewritings;
2374:                 $this->collRewritingsPartial = false;
2375:             }
2376:         }
2377: 
2378:         return $this->collRewritings;
2379:     }
2380: 
2381:     /**
2382:      * Sets a collection of Rewriting objects related by a one-to-many relationship
2383:      * to the current object.
2384:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2385:      * and new objects from the given Propel collection.
2386:      *
2387:      * @param PropelCollection $rewritings A Propel collection.
2388:      * @param PropelPDO $con Optional connection object
2389:      */
2390:     public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null)
2391:     {
2392:         $this->rewritingsScheduledForDeletion = $this->getRewritings(new Criteria(), $con)->diff($rewritings);
2393: 
2394:         foreach ($this->rewritingsScheduledForDeletion as $rewritingRemoved) {
2395:             $rewritingRemoved->setFolder(null);
2396:         }
2397: 
2398:         $this->collRewritings = null;
2399:         foreach ($rewritings as $rewriting) {
2400:             $this->addRewriting($rewriting);
2401:         }
2402: 
2403:         $this->collRewritings = $rewritings;
2404:         $this->collRewritingsPartial = false;
2405:     }
2406: 
2407:     /**
2408:      * Returns the number of related Rewriting objects.
2409:      *
2410:      * @param Criteria $criteria
2411:      * @param boolean $distinct
2412:      * @param PropelPDO $con
2413:      * @return int             Count of related Rewriting objects.
2414:      * @throws PropelException
2415:      */
2416:     public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2417:     {
2418:         $partial = $this->collRewritingsPartial && !$this->isNew();
2419:         if (null === $this->collRewritings || null !== $criteria || $partial) {
2420:             if ($this->isNew() && null === $this->collRewritings) {
2421:                 return 0;
2422:             } else {
2423:                 if($partial && !$criteria) {
2424:                     return count($this->getRewritings());
2425:                 }
2426:                 $query = RewritingQuery::create(null, $criteria);
2427:                 if ($distinct) {
2428:                     $query->distinct();
2429:                 }
2430: 
2431:                 return $query
2432:                     ->filterByFolder($this)
2433:                     ->count($con);
2434:             }
2435:         } else {
2436:             return count($this->collRewritings);
2437:         }
2438:     }
2439: 
2440:     /**
2441:      * Method called to associate a Rewriting object to this object
2442:      * through the Rewriting foreign key attribute.
2443:      *
2444:      * @param    Rewriting $l Rewriting
2445:      * @return Folder The current object (for fluent API support)
2446:      */
2447:     public function addRewriting(Rewriting $l)
2448:     {
2449:         if ($this->collRewritings === null) {
2450:             $this->initRewritings();
2451:             $this->collRewritingsPartial = true;
2452:         }
2453:         if (!$this->collRewritings->contains($l)) { // only add it if the **same** object is not already associated
2454:             $this->doAddRewriting($l);
2455:         }
2456: 
2457:         return $this;
2458:     }
2459: 
2460:     /**
2461:      * @param   Rewriting $rewriting The rewriting object to add.
2462:      */
2463:     protected function doAddRewriting($rewriting)
2464:     {
2465:         $this->collRewritings[]= $rewriting;
2466:         $rewriting->setFolder($this);
2467:     }
2468: 
2469:     /**
2470:      * @param   Rewriting $rewriting The rewriting object to remove.
2471:      */
2472:     public function removeRewriting($rewriting)
2473:     {
2474:         if ($this->getRewritings()->contains($rewriting)) {
2475:             $this->collRewritings->remove($this->collRewritings->search($rewriting));
2476:             if (null === $this->rewritingsScheduledForDeletion) {
2477:                 $this->rewritingsScheduledForDeletion = clone $this->collRewritings;
2478:                 $this->rewritingsScheduledForDeletion->clear();
2479:             }
2480:             $this->rewritingsScheduledForDeletion[]= $rewriting;
2481:             $rewriting->setFolder(null);
2482:         }
2483:     }
2484: 
2485: 
2486:     /**
2487:      * If this collection has already been initialized with
2488:      * an identical criteria, it returns the collection.
2489:      * Otherwise if this Folder is new, it will return
2490:      * an empty collection; or if this Folder has previously
2491:      * been saved, it will retrieve related Rewritings from storage.
2492:      *
2493:      * This method is protected by default in order to keep the public
2494:      * api reasonable.  You can provide public methods for those you
2495:      * actually need in Folder.
2496:      *
2497:      * @param Criteria $criteria optional Criteria object to narrow the query
2498:      * @param PropelPDO $con optional connection object
2499:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2500:      * @return PropelObjectCollection|Rewriting[] List of Rewriting objects
2501:      */
2502:     public function getRewritingsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2503:     {
2504:         $query = RewritingQuery::create(null, $criteria);
2505:         $query->joinWith('Product', $join_behavior);
2506: 
2507:         return $this->getRewritings($query, $con);
2508:     }
2509: 
2510: 
2511:     /**
2512:      * If this collection has already been initialized with
2513:      * an identical criteria, it returns the collection.
2514:      * Otherwise if this Folder is new, it will return
2515:      * an empty collection; or if this Folder has previously
2516:      * been saved, it will retrieve related Rewritings from storage.
2517:      *
2518:      * This method is protected by default in order to keep the public
2519:      * api reasonable.  You can provide public methods for those you
2520:      * actually need in Folder.
2521:      *
2522:      * @param Criteria $criteria optional Criteria object to narrow the query
2523:      * @param PropelPDO $con optional connection object
2524:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2525:      * @return PropelObjectCollection|Rewriting[] List of Rewriting objects
2526:      */
2527:     public function getRewritingsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2528:     {
2529:         $query = RewritingQuery::create(null, $criteria);
2530:         $query->joinWith('Category', $join_behavior);
2531: 
2532:         return $this->getRewritings($query, $con);
2533:     }
2534: 
2535: 
2536:     /**
2537:      * If this collection has already been initialized with
2538:      * an identical criteria, it returns the collection.
2539:      * Otherwise if this Folder is new, it will return
2540:      * an empty collection; or if this Folder has previously
2541:      * been saved, it will retrieve related Rewritings from storage.
2542:      *
2543:      * This method is protected by default in order to keep the public
2544:      * api reasonable.  You can provide public methods for those you
2545:      * actually need in Folder.
2546:      *
2547:      * @param Criteria $criteria optional Criteria object to narrow the query
2548:      * @param PropelPDO $con optional connection object
2549:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2550:      * @return PropelObjectCollection|Rewriting[] List of Rewriting objects
2551:      */
2552:     public function getRewritingsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2553:     {
2554:         $query = RewritingQuery::create(null, $criteria);
2555:         $query->joinWith('Content', $join_behavior);
2556: 
2557:         return $this->getRewritings($query, $con);
2558:     }
2559: 
2560:     /**
2561:      * Clears out the collContentFolders collection
2562:      *
2563:      * This does not modify the database; however, it will remove any associated objects, causing
2564:      * them to be refetched by subsequent calls to accessor method.
2565:      *
2566:      * @return void
2567:      * @see        addContentFolders()
2568:      */
2569:     public function clearContentFolders()
2570:     {
2571:         $this->collContentFolders = null; // important to set this to null since that means it is uninitialized
2572:         $this->collContentFoldersPartial = null;
2573:     }
2574: 
2575:     /**
2576:      * reset is the collContentFolders collection loaded partially
2577:      *
2578:      * @return void
2579:      */
2580:     public function resetPartialContentFolders($v = true)
2581:     {
2582:         $this->collContentFoldersPartial = $v;
2583:     }
2584: 
2585:     /**
2586:      * Initializes the collContentFolders collection.
2587:      *
2588:      * By default this just sets the collContentFolders collection to an empty array (like clearcollContentFolders());
2589:      * however, you may wish to override this method in your stub class to provide setting appropriate
2590:      * to your application -- for example, setting the initial array to the values stored in database.
2591:      *
2592:      * @param boolean $overrideExisting If set to true, the method call initializes
2593:      *                                        the collection even if it is not empty
2594:      *
2595:      * @return void
2596:      */
2597:     public function initContentFolders($overrideExisting = true)
2598:     {
2599:         if (null !== $this->collContentFolders && !$overrideExisting) {
2600:             return;
2601:         }
2602:         $this->collContentFolders = new PropelObjectCollection();
2603:         $this->collContentFolders->setModel('ContentFolder');
2604:     }
2605: 
2606:     /**
2607:      * Gets an array of ContentFolder objects which contain a foreign key that references this object.
2608:      *
2609:      * If the $criteria is not null, it is used to always fetch the results from the database.
2610:      * Otherwise the results are fetched from the database the first time, then cached.
2611:      * Next time the same method is called without $criteria, the cached collection is returned.
2612:      * If this Folder is new, it will return
2613:      * an empty collection or the current collection; the criteria is ignored on a new object.
2614:      *
2615:      * @param Criteria $criteria optional Criteria object to narrow the query
2616:      * @param PropelPDO $con optional connection object
2617:      * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects
2618:      * @throws PropelException
2619:      */
2620:     public function getContentFolders($criteria = null, PropelPDO $con = null)
2621:     {
2622:         $partial = $this->collContentFoldersPartial && !$this->isNew();
2623:         if (null === $this->collContentFolders || null !== $criteria  || $partial) {
2624:             if ($this->isNew() && null === $this->collContentFolders) {
2625:                 // return empty collection
2626:                 $this->initContentFolders();
2627:             } else {
2628:                 $collContentFolders = ContentFolderQuery::create(null, $criteria)
2629:                     ->filterByFolder($this)
2630:                     ->find($con);
2631:                 if (null !== $criteria) {
2632:                     if (false !== $this->collContentFoldersPartial && count($collContentFolders)) {
2633:                       $this->initContentFolders(false);
2634: 
2635:                       foreach($collContentFolders as $obj) {
2636:                         if (false == $this->collContentFolders->contains($obj)) {
2637:                           $this->collContentFolders->append($obj);
2638:                         }
2639:                       }
2640: 
2641:                       $this->collContentFoldersPartial = true;
2642:                     }
2643: 
2644:                     return $collContentFolders;
2645:                 }
2646: 
2647:                 if($partial && $this->collContentFolders) {
2648:                     foreach($this->collContentFolders as $obj) {
2649:                         if($obj->isNew()) {
2650:                             $collContentFolders[] = $obj;
2651:                         }
2652:                     }
2653:                 }
2654: 
2655:                 $this->collContentFolders = $collContentFolders;
2656:                 $this->collContentFoldersPartial = false;
2657:             }
2658:         }
2659: 
2660:         return $this->collContentFolders;
2661:     }
2662: 
2663:     /**
2664:      * Sets a collection of ContentFolder objects related by a one-to-many relationship
2665:      * to the current object.
2666:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2667:      * and new objects from the given Propel collection.
2668:      *
2669:      * @param PropelCollection $contentFolders A Propel collection.
2670:      * @param PropelPDO $con Optional connection object
2671:      */
2672:     public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null)
2673:     {
2674:         $this->contentFoldersScheduledForDeletion = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders);
2675: 
2676:         foreach ($this->contentFoldersScheduledForDeletion as $contentFolderRemoved) {
2677:             $contentFolderRemoved->setFolder(null);
2678:         }
2679: 
2680:         $this->collContentFolders = null;
2681:         foreach ($contentFolders as $contentFolder) {
2682:             $this->addContentFolder($contentFolder);
2683:         }
2684: 
2685:         $this->collContentFolders = $contentFolders;
2686:         $this->collContentFoldersPartial = false;
2687:     }
2688: 
2689:     /**
2690:      * Returns the number of related ContentFolder objects.
2691:      *
2692:      * @param Criteria $criteria
2693:      * @param boolean $distinct
2694:      * @param PropelPDO $con
2695:      * @return int             Count of related ContentFolder objects.
2696:      * @throws PropelException
2697:      */
2698:     public function countContentFolders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2699:     {
2700:         $partial = $this->collContentFoldersPartial && !$this->isNew();
2701:         if (null === $this->collContentFolders || null !== $criteria || $partial) {
2702:             if ($this->isNew() && null === $this->collContentFolders) {
2703:                 return 0;
2704:             } else {
2705:                 if($partial && !$criteria) {
2706:                     return count($this->getContentFolders());
2707:                 }
2708:                 $query = ContentFolderQuery::create(null, $criteria);
2709:                 if ($distinct) {
2710:                     $query->distinct();
2711:                 }
2712: 
2713:                 return $query
2714:                     ->filterByFolder($this)
2715:                     ->count($con);
2716:             }
2717:         } else {
2718:             return count($this->collContentFolders);
2719:         }
2720:     }
2721: 
2722:     /**
2723:      * Method called to associate a ContentFolder object to this object
2724:      * through the ContentFolder foreign key attribute.
2725:      *
2726:      * @param    ContentFolder $l ContentFolder
2727:      * @return Folder The current object (for fluent API support)
2728:      */
2729:     public function addContentFolder(ContentFolder $l)
2730:     {
2731:         if ($this->collContentFolders === null) {
2732:             $this->initContentFolders();
2733:             $this->collContentFoldersPartial = true;
2734:         }
2735:         if (!$this->collContentFolders->contains($l)) { // only add it if the **same** object is not already associated
2736:             $this->doAddContentFolder($l);
2737:         }
2738: 
2739:         return $this;
2740:     }
2741: 
2742:     /**
2743:      * @param   ContentFolder $contentFolder The contentFolder object to add.
2744:      */
2745:     protected function doAddContentFolder($contentFolder)
2746:     {
2747:         $this->collContentFolders[]= $contentFolder;
2748:         $contentFolder->setFolder($this);
2749:     }
2750: 
2751:     /**
2752:      * @param   ContentFolder $contentFolder The contentFolder object to remove.
2753:      */
2754:     public function removeContentFolder($contentFolder)
2755:     {
2756:         if ($this->getContentFolders()->contains($contentFolder)) {
2757:             $this->collContentFolders->remove($this->collContentFolders->search($contentFolder));
2758:             if (null === $this->contentFoldersScheduledForDeletion) {
2759:                 $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders;
2760:                 $this->contentFoldersScheduledForDeletion->clear();
2761:             }
2762:             $this->contentFoldersScheduledForDeletion[]= $contentFolder;
2763:             $contentFolder->setFolder(null);
2764:         }
2765:     }
2766: 
2767: 
2768:     /**
2769:      * If this collection has already been initialized with
2770:      * an identical criteria, it returns the collection.
2771:      * Otherwise if this Folder is new, it will return
2772:      * an empty collection; or if this Folder has previously
2773:      * been saved, it will retrieve related ContentFolders from storage.
2774:      *
2775:      * This method is protected by default in order to keep the public
2776:      * api reasonable.  You can provide public methods for those you
2777:      * actually need in Folder.
2778:      *
2779:      * @param Criteria $criteria optional Criteria object to narrow the query
2780:      * @param PropelPDO $con optional connection object
2781:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2782:      * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects
2783:      */
2784:     public function getContentFoldersJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2785:     {
2786:         $query = ContentFolderQuery::create(null, $criteria);
2787:         $query->joinWith('Content', $join_behavior);
2788: 
2789:         return $this->getContentFolders($query, $con);
2790:     }
2791: 
2792:     /**
2793:      * Clears out the collFolderI18ns collection
2794:      *
2795:      * This does not modify the database; however, it will remove any associated objects, causing
2796:      * them to be refetched by subsequent calls to accessor method.
2797:      *
2798:      * @return void
2799:      * @see        addFolderI18ns()
2800:      */
2801:     public function clearFolderI18ns()
2802:     {
2803:         $this->collFolderI18ns = null; // important to set this to null since that means it is uninitialized
2804:         $this->collFolderI18nsPartial = null;
2805:     }
2806: 
2807:     /**
2808:      * reset is the collFolderI18ns collection loaded partially
2809:      *
2810:      * @return void
2811:      */
2812:     public function resetPartialFolderI18ns($v = true)
2813:     {
2814:         $this->collFolderI18nsPartial = $v;
2815:     }
2816: 
2817:     /**
2818:      * Initializes the collFolderI18ns collection.
2819:      *
2820:      * By default this just sets the collFolderI18ns collection to an empty array (like clearcollFolderI18ns());
2821:      * however, you may wish to override this method in your stub class to provide setting appropriate
2822:      * to your application -- for example, setting the initial array to the values stored in database.
2823:      *
2824:      * @param boolean $overrideExisting If set to true, the method call initializes
2825:      *                                        the collection even if it is not empty
2826:      *
2827:      * @return void
2828:      */
2829:     public function initFolderI18ns($overrideExisting = true)
2830:     {
2831:         if (null !== $this->collFolderI18ns && !$overrideExisting) {
2832:             return;
2833:         }
2834:         $this->collFolderI18ns = new PropelObjectCollection();
2835:         $this->collFolderI18ns->setModel('FolderI18n');
2836:     }
2837: 
2838:     /**
2839:      * Gets an array of FolderI18n objects which contain a foreign key that references this object.
2840:      *
2841:      * If the $criteria is not null, it is used to always fetch the results from the database.
2842:      * Otherwise the results are fetched from the database the first time, then cached.
2843:      * Next time the same method is called without $criteria, the cached collection is returned.
2844:      * If this Folder is new, it will return
2845:      * an empty collection or the current collection; the criteria is ignored on a new object.
2846:      *
2847:      * @param Criteria $criteria optional Criteria object to narrow the query
2848:      * @param PropelPDO $con optional connection object
2849:      * @return PropelObjectCollection|FolderI18n[] List of FolderI18n objects
2850:      * @throws PropelException
2851:      */
2852:     public function getFolderI18ns($criteria = null, PropelPDO $con = null)
2853:     {
2854:         $partial = $this->collFolderI18nsPartial && !$this->isNew();
2855:         if (null === $this->collFolderI18ns || null !== $criteria  || $partial) {
2856:             if ($this->isNew() && null === $this->collFolderI18ns) {
2857:                 // return empty collection
2858:                 $this->initFolderI18ns();
2859:             } else {
2860:                 $collFolderI18ns = FolderI18nQuery::create(null, $criteria)
2861:                     ->filterByFolder($this)
2862:                     ->find($con);
2863:                 if (null !== $criteria) {
2864:                     if (false !== $this->collFolderI18nsPartial && count($collFolderI18ns)) {
2865:                       $this->initFolderI18ns(false);
2866: 
2867:                       foreach($collFolderI18ns as $obj) {
2868:                         if (false == $this->collFolderI18ns->contains($obj)) {
2869:                           $this->collFolderI18ns->append($obj);
2870:                         }
2871:                       }
2872: 
2873:                       $this->collFolderI18nsPartial = true;
2874:                     }
2875: 
2876:                     return $collFolderI18ns;
2877:                 }
2878: 
2879:                 if($partial && $this->collFolderI18ns) {
2880:                     foreach($this->collFolderI18ns as $obj) {
2881:                         if($obj->isNew()) {
2882:                             $collFolderI18ns[] = $obj;
2883:                         }
2884:                     }
2885:                 }
2886: 
2887:                 $this->collFolderI18ns = $collFolderI18ns;
2888:                 $this->collFolderI18nsPartial = false;
2889:             }
2890:         }
2891: 
2892:         return $this->collFolderI18ns;
2893:     }
2894: 
2895:     /**
2896:      * Sets a collection of FolderI18n objects related by a one-to-many relationship
2897:      * to the current object.
2898:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2899:      * and new objects from the given Propel collection.
2900:      *
2901:      * @param PropelCollection $folderI18ns A Propel collection.
2902:      * @param PropelPDO $con Optional connection object
2903:      */
2904:     public function setFolderI18ns(PropelCollection $folderI18ns, PropelPDO $con = null)
2905:     {
2906:         $this->folderI18nsScheduledForDeletion = $this->getFolderI18ns(new Criteria(), $con)->diff($folderI18ns);
2907: 
2908:         foreach ($this->folderI18nsScheduledForDeletion as $folderI18nRemoved) {
2909:             $folderI18nRemoved->setFolder(null);
2910:         }
2911: 
2912:         $this->collFolderI18ns = null;
2913:         foreach ($folderI18ns as $folderI18n) {
2914:             $this->addFolderI18n($folderI18n);
2915:         }
2916: 
2917:         $this->collFolderI18ns = $folderI18ns;
2918:         $this->collFolderI18nsPartial = false;
2919:     }
2920: 
2921:     /**
2922:      * Returns the number of related FolderI18n objects.
2923:      *
2924:      * @param Criteria $criteria
2925:      * @param boolean $distinct
2926:      * @param PropelPDO $con
2927:      * @return int             Count of related FolderI18n objects.
2928:      * @throws PropelException
2929:      */
2930:     public function countFolderI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2931:     {
2932:         $partial = $this->collFolderI18nsPartial && !$this->isNew();
2933:         if (null === $this->collFolderI18ns || null !== $criteria || $partial) {
2934:             if ($this->isNew() && null === $this->collFolderI18ns) {
2935:                 return 0;
2936:             } else {
2937:                 if($partial && !$criteria) {
2938:                     return count($this->getFolderI18ns());
2939:                 }
2940:                 $query = FolderI18nQuery::create(null, $criteria);
2941:                 if ($distinct) {
2942:                     $query->distinct();
2943:                 }
2944: 
2945:                 return $query
2946:                     ->filterByFolder($this)
2947:                     ->count($con);
2948:             }
2949:         } else {
2950:             return count($this->collFolderI18ns);
2951:         }
2952:     }
2953: 
2954:     /**
2955:      * Method called to associate a FolderI18n object to this object
2956:      * through the FolderI18n foreign key attribute.
2957:      *
2958:      * @param    FolderI18n $l FolderI18n
2959:      * @return Folder The current object (for fluent API support)
2960:      */
2961:     public function addFolderI18n(FolderI18n $l)
2962:     {
2963:         if ($l && $locale = $l->getLocale()) {
2964:             $this->setLocale($locale);
2965:             $this->currentTranslations[$locale] = $l;
2966:         }
2967:         if ($this->collFolderI18ns === null) {
2968:             $this->initFolderI18ns();
2969:             $this->collFolderI18nsPartial = true;
2970:         }
2971:         if (!$this->collFolderI18ns->contains($l)) { // only add it if the **same** object is not already associated
2972:             $this->doAddFolderI18n($l);
2973:         }
2974: 
2975:         return $this;
2976:     }
2977: 
2978:     /**
2979:      * @param   FolderI18n $folderI18n The folderI18n object to add.
2980:      */
2981:     protected function doAddFolderI18n($folderI18n)
2982:     {
2983:         $this->collFolderI18ns[]= $folderI18n;
2984:         $folderI18n->setFolder($this);
2985:     }
2986: 
2987:     /**
2988:      * @param   FolderI18n $folderI18n The folderI18n object to remove.
2989:      */
2990:     public function removeFolderI18n($folderI18n)
2991:     {
2992:         if ($this->getFolderI18ns()->contains($folderI18n)) {
2993:             $this->collFolderI18ns->remove($this->collFolderI18ns->search($folderI18n));
2994:             if (null === $this->folderI18nsScheduledForDeletion) {
2995:                 $this->folderI18nsScheduledForDeletion = clone $this->collFolderI18ns;
2996:                 $this->folderI18nsScheduledForDeletion->clear();
2997:             }
2998:             $this->folderI18nsScheduledForDeletion[]= $folderI18n;
2999:             $folderI18n->setFolder(null);
3000:         }
3001:     }
3002: 
3003:     /**
3004:      * Clears out the collFolderVersions collection
3005:      *
3006:      * This does not modify the database; however, it will remove any associated objects, causing
3007:      * them to be refetched by subsequent calls to accessor method.
3008:      *
3009:      * @return void
3010:      * @see        addFolderVersions()
3011:      */
3012:     public function clearFolderVersions()
3013:     {
3014:         $this->collFolderVersions = null; // important to set this to null since that means it is uninitialized
3015:         $this->collFolderVersionsPartial = null;
3016:     }
3017: 
3018:     /**
3019:      * reset is the collFolderVersions collection loaded partially
3020:      *
3021:      * @return void
3022:      */
3023:     public function resetPartialFolderVersions($v = true)
3024:     {
3025:         $this->collFolderVersionsPartial = $v;
3026:     }
3027: 
3028:     /**
3029:      * Initializes the collFolderVersions collection.
3030:      *
3031:      * By default this just sets the collFolderVersions collection to an empty array (like clearcollFolderVersions());
3032:      * however, you may wish to override this method in your stub class to provide setting appropriate
3033:      * to your application -- for example, setting the initial array to the values stored in database.
3034:      *
3035:      * @param boolean $overrideExisting If set to true, the method call initializes
3036:      *                                        the collection even if it is not empty
3037:      *
3038:      * @return void
3039:      */
3040:     public function initFolderVersions($overrideExisting = true)
3041:     {
3042:         if (null !== $this->collFolderVersions && !$overrideExisting) {
3043:             return;
3044:         }
3045:         $this->collFolderVersions = new PropelObjectCollection();
3046:         $this->collFolderVersions->setModel('FolderVersion');
3047:     }
3048: 
3049:     /**
3050:      * Gets an array of FolderVersion objects which contain a foreign key that references this object.
3051:      *
3052:      * If the $criteria is not null, it is used to always fetch the results from the database.
3053:      * Otherwise the results are fetched from the database the first time, then cached.
3054:      * Next time the same method is called without $criteria, the cached collection is returned.
3055:      * If this Folder is new, it will return
3056:      * an empty collection or the current collection; the criteria is ignored on a new object.
3057:      *
3058:      * @param Criteria $criteria optional Criteria object to narrow the query
3059:      * @param PropelPDO $con optional connection object
3060:      * @return PropelObjectCollection|FolderVersion[] List of FolderVersion objects
3061:      * @throws PropelException
3062:      */
3063:     public function getFolderVersions($criteria = null, PropelPDO $con = null)
3064:     {
3065:         $partial = $this->collFolderVersionsPartial && !$this->isNew();
3066:         if (null === $this->collFolderVersions || null !== $criteria  || $partial) {
3067:             if ($this->isNew() && null === $this->collFolderVersions) {
3068:                 // return empty collection
3069:                 $this->initFolderVersions();
3070:             } else {
3071:                 $collFolderVersions = FolderVersionQuery::create(null, $criteria)
3072:                     ->filterByFolder($this)
3073:                     ->find($con);
3074:                 if (null !== $criteria) {
3075:                     if (false !== $this->collFolderVersionsPartial && count($collFolderVersions)) {
3076:                       $this->initFolderVersions(false);
3077: 
3078:                       foreach($collFolderVersions as $obj) {
3079:                         if (false == $this->collFolderVersions->contains($obj)) {
3080:                           $this->collFolderVersions->append($obj);
3081:                         }
3082:                       }
3083: 
3084:                       $this->collFolderVersionsPartial = true;
3085:                     }
3086: 
3087:                     return $collFolderVersions;
3088:                 }
3089: 
3090:                 if($partial && $this->collFolderVersions) {
3091:                     foreach($this->collFolderVersions as $obj) {
3092:                         if($obj->isNew()) {
3093:                             $collFolderVersions[] = $obj;
3094:                         }
3095:                     }
3096:                 }
3097: 
3098:                 $this->collFolderVersions = $collFolderVersions;
3099:                 $this->collFolderVersionsPartial = false;
3100:             }
3101:         }
3102: 
3103:         return $this->collFolderVersions;
3104:     }
3105: 
3106:     /**
3107:      * Sets a collection of FolderVersion objects related by a one-to-many relationship
3108:      * to the current object.
3109:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
3110:      * and new objects from the given Propel collection.
3111:      *
3112:      * @param PropelCollection $folderVersions A Propel collection.
3113:      * @param PropelPDO $con Optional connection object
3114:      */
3115:     public function setFolderVersions(PropelCollection $folderVersions, PropelPDO $con = null)
3116:     {
3117:         $this->folderVersionsScheduledForDeletion = $this->getFolderVersions(new Criteria(), $con)->diff($folderVersions);
3118: 
3119:         foreach ($this->folderVersionsScheduledForDeletion as $folderVersionRemoved) {
3120:             $folderVersionRemoved->setFolder(null);
3121:         }
3122: 
3123:         $this->collFolderVersions = null;
3124:         foreach ($folderVersions as $folderVersion) {
3125:             $this->addFolderVersion($folderVersion);
3126:         }
3127: 
3128:         $this->collFolderVersions = $folderVersions;
3129:         $this->collFolderVersionsPartial = false;
3130:     }
3131: 
3132:     /**
3133:      * Returns the number of related FolderVersion objects.
3134:      *
3135:      * @param Criteria $criteria
3136:      * @param boolean $distinct
3137:      * @param PropelPDO $con
3138:      * @return int             Count of related FolderVersion objects.
3139:      * @throws PropelException
3140:      */
3141:     public function countFolderVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3142:     {
3143:         $partial = $this->collFolderVersionsPartial && !$this->isNew();
3144:         if (null === $this->collFolderVersions || null !== $criteria || $partial) {
3145:             if ($this->isNew() && null === $this->collFolderVersions) {
3146:                 return 0;
3147:             } else {
3148:                 if($partial && !$criteria) {
3149:                     return count($this->getFolderVersions());
3150:                 }
3151:                 $query = FolderVersionQuery::create(null, $criteria);
3152:                 if ($distinct) {
3153:                     $query->distinct();
3154:                 }
3155: 
3156:                 return $query
3157:                     ->filterByFolder($this)
3158:                     ->count($con);
3159:             }
3160:         } else {
3161:             return count($this->collFolderVersions);
3162:         }
3163:     }
3164: 
3165:     /**
3166:      * Method called to associate a FolderVersion object to this object
3167:      * through the FolderVersion foreign key attribute.
3168:      *
3169:      * @param    FolderVersion $l FolderVersion
3170:      * @return Folder The current object (for fluent API support)
3171:      */
3172:     public function addFolderVersion(FolderVersion $l)
3173:     {
3174:         if ($this->collFolderVersions === null) {
3175:             $this->initFolderVersions();
3176:             $this->collFolderVersionsPartial = true;
3177:         }
3178:         if (!$this->collFolderVersions->contains($l)) { // only add it if the **same** object is not already associated
3179:             $this->doAddFolderVersion($l);
3180:         }
3181: 
3182:         return $this;
3183:     }
3184: 
3185:     /**
3186:      * @param   FolderVersion $folderVersion The folderVersion object to add.
3187:      */
3188:     protected function doAddFolderVersion($folderVersion)
3189:     {
3190:         $this->collFolderVersions[]= $folderVersion;
3191:         $folderVersion->setFolder($this);
3192:     }
3193: 
3194:     /**
3195:      * @param   FolderVersion $folderVersion The folderVersion object to remove.
3196:      */
3197:     public function removeFolderVersion($folderVersion)
3198:     {
3199:         if ($this->getFolderVersions()->contains($folderVersion)) {
3200:             $this->collFolderVersions->remove($this->collFolderVersions->search($folderVersion));
3201:             if (null === $this->folderVersionsScheduledForDeletion) {
3202:                 $this->folderVersionsScheduledForDeletion = clone $this->collFolderVersions;
3203:                 $this->folderVersionsScheduledForDeletion->clear();
3204:             }
3205:             $this->folderVersionsScheduledForDeletion[]= $folderVersion;
3206:             $folderVersion->setFolder(null);
3207:         }
3208:     }
3209: 
3210:     /**
3211:      * Clears the current object and sets all attributes to their default values
3212:      */
3213:     public function clear()
3214:     {
3215:         $this->id = null;
3216:         $this->parent = null;
3217:         $this->link = null;
3218:         $this->visible = null;
3219:         $this->position = null;
3220:         $this->created_at = null;
3221:         $this->updated_at = null;
3222:         $this->version = null;
3223:         $this->version_created_at = null;
3224:         $this->version_created_by = null;
3225:         $this->alreadyInSave = false;
3226:         $this->alreadyInValidation = false;
3227:         $this->clearAllReferences();
3228:         $this->applyDefaultValues();
3229:         $this->resetModified();
3230:         $this->setNew(true);
3231:         $this->setDeleted(false);
3232:     }
3233: 
3234:     /**
3235:      * Resets all references to other model objects or collections of model objects.
3236:      *
3237:      * This method is a user-space workaround for PHP's inability to garbage collect
3238:      * objects with circular references (even in PHP 5.3). This is currently necessary
3239:      * when using Propel in certain daemon or large-volumne/high-memory operations.
3240:      *
3241:      * @param boolean $deep Whether to also clear the references on all referrer objects.
3242:      */
3243:     public function clearAllReferences($deep = false)
3244:     {
3245:         if ($deep) {
3246:             if ($this->collImages) {
3247:                 foreach ($this->collImages as $o) {
3248:                     $o->clearAllReferences($deep);
3249:                 }
3250:             }
3251:             if ($this->collDocuments) {
3252:                 foreach ($this->collDocuments as $o) {
3253:                     $o->clearAllReferences($deep);
3254:                 }
3255:             }
3256:             if ($this->collRewritings) {
3257:                 foreach ($this->collRewritings as $o) {
3258:                     $o->clearAllReferences($deep);
3259:                 }
3260:             }
3261:             if ($this->collContentFolders) {
3262:                 foreach ($this->collContentFolders as $o) {
3263:                     $o->clearAllReferences($deep);
3264:                 }
3265:             }
3266:             if ($this->collFolderI18ns) {
3267:                 foreach ($this->collFolderI18ns as $o) {
3268:                     $o->clearAllReferences($deep);
3269:                 }
3270:             }
3271:             if ($this->collFolderVersions) {
3272:                 foreach ($this->collFolderVersions as $o) {
3273:                     $o->clearAllReferences($deep);
3274:                 }
3275:             }
3276:         } // if ($deep)
3277: 
3278:         // i18n behavior
3279:         $this->currentLocale = 'en_EN';
3280:         $this->currentTranslations = null;
3281: 
3282:         if ($this->collImages instanceof PropelCollection) {
3283:             $this->collImages->clearIterator();
3284:         }
3285:         $this->collImages = null;
3286:         if ($this->collDocuments instanceof PropelCollection) {
3287:             $this->collDocuments->clearIterator();
3288:         }
3289:         $this->collDocuments = null;
3290:         if ($this->collRewritings instanceof PropelCollection) {
3291:             $this->collRewritings->clearIterator();
3292:         }
3293:         $this->collRewritings = null;
3294:         if ($this->collContentFolders instanceof PropelCollection) {
3295:             $this->collContentFolders->clearIterator();
3296:         }
3297:         $this->collContentFolders = null;
3298:         if ($this->collFolderI18ns instanceof PropelCollection) {
3299:             $this->collFolderI18ns->clearIterator();
3300:         }
3301:         $this->collFolderI18ns = null;
3302:         if ($this->collFolderVersions instanceof PropelCollection) {
3303:             $this->collFolderVersions->clearIterator();
3304:         }
3305:         $this->collFolderVersions = null;
3306:     }
3307: 
3308:     /**
3309:      * return the string representation of this object
3310:      *
3311:      * @return string
3312:      */
3313:     public function __toString()
3314:     {
3315:         return (string) $this->exportTo(FolderPeer::DEFAULT_STRING_FORMAT);
3316:     }
3317: 
3318:     /**
3319:      * return true is the object is in saving state
3320:      *
3321:      * @return boolean
3322:      */
3323:     public function isAlreadyInSave()
3324:     {
3325:         return $this->alreadyInSave;
3326:     }
3327: 
3328:     // timestampable behavior
3329: 
3330:     /**
3331:      * Mark the current object so that the update date doesn't get updated during next save
3332:      *
3333:      * @return     Folder The current object (for fluent API support)
3334:      */
3335:     public function keepUpdateDateUnchanged()
3336:     {
3337:         $this->modifiedColumns[] = FolderPeer::UPDATED_AT;
3338: 
3339:         return $this;
3340:     }
3341: 
3342:     // i18n behavior
3343: 
3344:     /**
3345:      * Sets the locale for translations
3346:      *
3347:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
3348:      *
3349:      * @return    Folder The current object (for fluent API support)
3350:      */
3351:     public function setLocale($locale = 'en_EN')
3352:     {
3353:         $this->currentLocale = $locale;
3354: 
3355:         return $this;
3356:     }
3357: 
3358:     /**
3359:      * Gets the locale for translations
3360:      *
3361:      * @return    string $locale Locale to use for the translation, e.g. 'fr_FR'
3362:      */
3363:     public function getLocale()
3364:     {
3365:         return $this->currentLocale;
3366:     }
3367: 
3368:     /**
3369:      * Returns the current translation for a given locale
3370:      *
3371:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
3372:      * @param     PropelPDO $con an optional connection object
3373:      *
3374:      * @return FolderI18n */
3375:     public function getTranslation($locale = 'en_EN', PropelPDO $con = null)
3376:     {
3377:         if (!isset($this->currentTranslations[$locale])) {
3378:             if (null !== $this->collFolderI18ns) {
3379:                 foreach ($this->collFolderI18ns as $translation) {
3380:                     if ($translation->getLocale() == $locale) {
3381:                         $this->currentTranslations[$locale] = $translation;
3382: 
3383:                         return $translation;
3384:                     }
3385:                 }
3386:             }
3387:             if ($this->isNew()) {
3388:                 $translation = new FolderI18n();
3389:                 $translation->setLocale($locale);
3390:             } else {
3391:                 $translation = FolderI18nQuery::create()
3392:                     ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
3393:                     ->findOneOrCreate($con);
3394:                 $this->currentTranslations[$locale] = $translation;
3395:             }
3396:             $this->addFolderI18n($translation);
3397:         }
3398: 
3399:         return $this->currentTranslations[$locale];
3400:     }
3401: 
3402:     /**
3403:      * Remove the translation for a given locale
3404:      *
3405:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
3406:      * @param     PropelPDO $con an optional connection object
3407:      *
3408:      * @return    Folder The current object (for fluent API support)
3409:      */
3410:     public function removeTranslation($locale = 'en_EN', PropelPDO $con = null)
3411:     {
3412:         if (!$this->isNew()) {
3413:             FolderI18nQuery::create()
3414:                 ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
3415:                 ->delete($con);
3416:         }
3417:         if (isset($this->currentTranslations[$locale])) {
3418:             unset($this->currentTranslations[$locale]);
3419:         }
3420:         foreach ($this->collFolderI18ns as $key => $translation) {
3421:             if ($translation->getLocale() == $locale) {
3422:                 unset($this->collFolderI18ns[$key]);
3423:                 break;
3424:             }
3425:         }
3426: 
3427:         return $this;
3428:     }
3429: 
3430:     /**
3431:      * Returns the current translation
3432:      *
3433:      * @param     PropelPDO $con an optional connection object
3434:      *
3435:      * @return FolderI18n */
3436:     public function getCurrentTranslation(PropelPDO $con = null)
3437:     {
3438:         return $this->getTranslation($this->getLocale(), $con);
3439:     }
3440: 
3441: 
3442:         /**
3443:          * Get the [title] column value.
3444:          *
3445:          * @return string
3446:          */
3447:         public function getTitle()
3448:         {
3449:         return $this->getCurrentTranslation()->getTitle();
3450:     }
3451: 
3452: 
3453:         /**
3454:          * Set the value of [title] column.
3455:          *
3456:          * @param string $v new value
3457:          * @return FolderI18n The current object (for fluent API support)
3458:          */
3459:         public function setTitle($v)
3460:         {    $this->getCurrentTranslation()->setTitle($v);
3461: 
3462:         return $this;
3463:     }
3464: 
3465: 
3466:         /**
3467:          * Get the [description] column value.
3468:          *
3469:          * @return string
3470:          */
3471:         public function getDescription()
3472:         {
3473:         return $this->getCurrentTranslation()->getDescription();
3474:     }
3475: 
3476: 
3477:         /**
3478:          * Set the value of [description] column.
3479:          *
3480:          * @param string $v new value
3481:          * @return FolderI18n The current object (for fluent API support)
3482:          */
3483:         public function setDescription($v)
3484:         {    $this->getCurrentTranslation()->setDescription($v);
3485: 
3486:         return $this;
3487:     }
3488: 
3489: 
3490:         /**
3491:          * Get the [chapo] column value.
3492:          *
3493:          * @return string
3494:          */
3495:         public function getChapo()
3496:         {
3497:         return $this->getCurrentTranslation()->getChapo();
3498:     }
3499: 
3500: 
3501:         /**
3502:          * Set the value of [chapo] column.
3503:          *
3504:          * @param string $v new value
3505:          * @return FolderI18n The current object (for fluent API support)
3506:          */
3507:         public function setChapo($v)
3508:         {    $this->getCurrentTranslation()->setChapo($v);
3509: 
3510:         return $this;
3511:     }
3512: 
3513: 
3514:         /**
3515:          * Get the [postscriptum] column value.
3516:          *
3517:          * @return string
3518:          */
3519:         public function getPostscriptum()
3520:         {
3521:         return $this->getCurrentTranslation()->getPostscriptum();
3522:     }
3523: 
3524: 
3525:         /**
3526:          * Set the value of [postscriptum] column.
3527:          *
3528:          * @param string $v new value
3529:          * @return FolderI18n The current object (for fluent API support)
3530:          */
3531:         public function setPostscriptum($v)
3532:         {    $this->getCurrentTranslation()->setPostscriptum($v);
3533: 
3534:         return $this;
3535:     }
3536: 
3537:     // versionable behavior
3538: 
3539:     /**
3540:      * Enforce a new Version of this object upon next save.
3541:      *
3542:      * @return Folder
3543:      */
3544:     public function enforceVersioning()
3545:     {
3546:         $this->enforceVersion = true;
3547: 
3548:         return $this;
3549:     }
3550: 
3551:     /**
3552:      * Checks whether the current state must be recorded as a version
3553:      *
3554:      * @param PropelPDO $con An optional PropelPDO connection to use.
3555:      *
3556:      * @return  boolean
3557:      */
3558:     public function isVersioningNecessary($con = null)
3559:     {
3560:         if ($this->alreadyInSave) {
3561:             return false;
3562:         }
3563: 
3564:         if ($this->enforceVersion) {
3565:             return true;
3566:         }
3567: 
3568:         if (FolderPeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) {
3569:             return true;
3570:         }
3571: 
3572:         return false;
3573:     }
3574: 
3575:     /**
3576:      * Creates a version of the current object and saves it.
3577:      *
3578:      * @param   PropelPDO $con the connection to use
3579:      *
3580:      * @return  FolderVersion A version object
3581:      */
3582:     public function addVersion($con = null)
3583:     {
3584:         $this->enforceVersion = false;
3585: 
3586:         $version = new FolderVersion();
3587:         $version->setId($this->getId());
3588:         $version->setParent($this->getParent());
3589:         $version->setLink($this->getLink());
3590:         $version->setVisible($this->getVisible());
3591:         $version->setPosition($this->getPosition());
3592:         $version->setCreatedAt($this->getCreatedAt());
3593:         $version->setUpdatedAt($this->getUpdatedAt());
3594:         $version->setVersion($this->getVersion());
3595:         $version->setVersionCreatedAt($this->getVersionCreatedAt());
3596:         $version->setVersionCreatedBy($this->getVersionCreatedBy());
3597:         $version->setFolder($this);
3598:         $version->save($con);
3599: 
3600:         return $version;
3601:     }
3602: 
3603:     /**
3604:      * Sets the properties of the curent object to the value they had at a specific version
3605:      *
3606:      * @param   integer $versionNumber The version number to read
3607:      * @param   PropelPDO $con the connection to use
3608:      *
3609:      * @return  Folder The current object (for fluent API support)
3610:      * @throws  PropelException - if no object with the given version can be found.
3611:      */
3612:     public function toVersion($versionNumber, $con = null)
3613:     {
3614:         $version = $this->getOneVersion($versionNumber, $con);
3615:         if (!$version) {
3616:             throw new PropelException(sprintf('No Folder object found with version %d', $version));
3617:         }
3618:         $this->populateFromVersion($version, $con);
3619: 
3620:         return $this;
3621:     }
3622: 
3623:     /**
3624:      * Sets the properties of the curent object to the value they had at a specific version
3625:      *
3626:      * @param   FolderVersion $version The version object to use
3627:      * @param   PropelPDO $con the connection to use
3628:      * @param   array $loadedObjects objects thats been loaded in a chain of populateFromVersion calls on referrer or fk objects.
3629:      *
3630:      * @return  Folder The current object (for fluent API support)
3631:      */
3632:     public function populateFromVersion($version, $con = null, &$loadedObjects = array())
3633:     {
3634: 
3635:         $loadedObjects['Folder'][$version->getId()][$version->getVersion()] = $this;
3636:         $this->setId($version->getId());
3637:         $this->setParent($version->getParent());
3638:         $this->setLink($version->getLink());
3639:         $this->setVisible($version->getVisible());
3640:         $this->setPosition($version->getPosition());
3641:         $this->setCreatedAt($version->getCreatedAt());
3642:         $this->setUpdatedAt($version->getUpdatedAt());
3643:         $this->setVersion($version->getVersion());
3644:         $this->setVersionCreatedAt($version->getVersionCreatedAt());
3645:         $this->setVersionCreatedBy($version->getVersionCreatedBy());
3646: 
3647:         return $this;
3648:     }
3649: 
3650:     /**
3651:      * Gets the latest persisted version number for the current object
3652:      *
3653:      * @param   PropelPDO $con the connection to use
3654:      *
3655:      * @return  integer
3656:      */
3657:     public function getLastVersionNumber($con = null)
3658:     {
3659:         $v = FolderVersionQuery::create()
3660:             ->filterByFolder($this)
3661:             ->orderByVersion('desc')
3662:             ->findOne($con);
3663:         if (!$v) {
3664:             return 0;
3665:         }
3666: 
3667:         return $v->getVersion();
3668:     }
3669: 
3670:     /**
3671:      * Checks whether the current object is the latest one
3672:      *
3673:      * @param   PropelPDO $con the connection to use
3674:      *
3675:      * @return  boolean
3676:      */
3677:     public function isLastVersion($con = null)
3678:     {
3679:         return $this->getLastVersionNumber($con) == $this->getVersion();
3680:     }
3681: 
3682:     /**
3683:      * Retrieves a version object for this entity and a version number
3684:      *
3685:      * @param   integer $versionNumber The version number to read
3686:      * @param   PropelPDO $con the connection to use
3687:      *
3688:      * @return  FolderVersion A version object
3689:      */
3690:     public function getOneVersion($versionNumber, $con = null)
3691:     {
3692:         return FolderVersionQuery::create()
3693:             ->filterByFolder($this)
3694:             ->filterByVersion($versionNumber)
3695:             ->findOne($con);
3696:     }
3697: 
3698:     /**
3699:      * Gets all the versions of this object, in incremental order
3700:      *
3701:      * @param   PropelPDO $con the connection to use
3702:      *
3703:      * @return  PropelObjectCollection A list of FolderVersion objects
3704:      */
3705:     public function getAllVersions($con = null)
3706:     {
3707:         $criteria = new Criteria();
3708:         $criteria->addAscendingOrderByColumn(FolderVersionPeer::VERSION);
3709: 
3710:         return $this->getFolderVersions($criteria, $con);
3711:     }
3712: 
3713:     /**
3714:      * Compares the current object with another of its version.
3715:      * <code>
3716:      * print_r($book->compareVersion(1));
3717:      * => array(
3718:      *   '1' => array('Title' => 'Book title at version 1'),
3719:      *   '2' => array('Title' => 'Book title at version 2')
3720:      * );
3721:      * </code>
3722:      *
3723:      * @param   integer   $versionNumber
3724:      * @param   string    $keys Main key used for the result diff (versions|columns)
3725:      * @param   PropelPDO $con the connection to use
3726:      * @param   array     $ignoredColumns  The columns to exclude from the diff.
3727:      *
3728:      * @return  array A list of differences
3729:      */
3730:     public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
3731:     {
3732:         $fromVersion = $this->toArray();
3733:         $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
3734: 
3735:         return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
3736:     }
3737: 
3738:     /**
3739:      * Compares two versions of the current object.
3740:      * <code>
3741:      * print_r($book->compareVersions(1, 2));
3742:      * => array(
3743:      *   '1' => array('Title' => 'Book title at version 1'),
3744:      *   '2' => array('Title' => 'Book title at version 2')
3745:      * );
3746:      * </code>
3747:      *
3748:      * @param   integer   $fromVersionNumber
3749:      * @param   integer   $toVersionNumber
3750:      * @param   string    $keys Main key used for the result diff (versions|columns)
3751:      * @param   PropelPDO $con the connection to use
3752:      * @param   array     $ignoredColumns  The columns to exclude from the diff.
3753:      *
3754:      * @return  array A list of differences
3755:      */
3756:     public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
3757:     {
3758:         $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
3759:         $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
3760: 
3761:         return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
3762:     }
3763: 
3764:     /**
3765:      * Computes the diff between two versions.
3766:      * <code>
3767:      * print_r($this->computeDiff(1, 2));
3768:      * => array(
3769:      *   '1' => array('Title' => 'Book title at version 1'),
3770:      *   '2' => array('Title' => 'Book title at version 2')
3771:      * );
3772:      * </code>
3773:      *
3774:      * @param   array     $fromVersion     An array representing the original version.
3775:      * @param   array     $toVersion       An array representing the destination version.
3776:      * @param   string    $keys            Main key used for the result diff (versions|columns).
3777:      * @param   array     $ignoredColumns  The columns to exclude from the diff.
3778:      *
3779:      * @return  array A list of differences
3780:      */
3781:     protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
3782:     {
3783:         $fromVersionNumber = $fromVersion['Version'];
3784:         $toVersionNumber = $toVersion['Version'];
3785:         $ignoredColumns = array_merge(array(
3786:             'Version',
3787:             'VersionCreatedAt',
3788:             'VersionCreatedBy',
3789:         ), $ignoredColumns);
3790:         $diff = array();
3791:         foreach ($fromVersion as $key => $value) {
3792:             if (in_array($key, $ignoredColumns)) {
3793:                 continue;
3794:             }
3795:             if ($toVersion[$key] != $value) {
3796:                 switch ($keys) {
3797:                     case 'versions':
3798:                         $diff[$fromVersionNumber][$key] = $value;
3799:                         $diff[$toVersionNumber][$key] = $toVersion[$key];
3800:                         break;
3801:                     default:
3802:                         $diff[$key] = array(
3803:                             $fromVersionNumber => $value,
3804:                             $toVersionNumber => $toVersion[$key],
3805:                         );
3806:                         break;
3807:                 }
3808:             }
3809:         }
3810: 
3811:         return $diff;
3812:     }
3813:     /**
3814:      * retrieve the last $number versions.
3815:      *
3816:      * @param integer $number the number of record to return.
3817:      * @param FolderVersionQuery|Criteria $criteria Additional criteria to filter.
3818:      * @param PropelPDO $con An optional connection to use.
3819:      *
3820:      * @return PropelCollection|FolderVersion[] List of FolderVersion objects
3821:      */
3822:     public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null)
3823:     {
3824:         $criteria = FolderVersionQuery::create(null, $criteria);
3825:         $criteria->addDescendingOrderByColumn(FolderVersionPeer::VERSION);
3826:         $criteria->limit($number);
3827: 
3828:         return $this->getFolderVersions($criteria, $con);
3829:     }
3830: }
3831: 
thelia API documentation generated by ApiGen 2.8.0