Overview

Namespaces

  • Thelia
    • Action
    • Controller
    • Core
      • Bundle
      • Event
      • EventListener
      • Template
        • BaseParam
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools
    • Tpex
      • BaseParam
      • Exception
      • Loop
      • Tests

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\AttributeCategory;
  19: use Thelia\Model\AttributeCategoryQuery;
  20: use Thelia\Model\Category;
  21: use Thelia\Model\CategoryI18n;
  22: use Thelia\Model\CategoryI18nQuery;
  23: use Thelia\Model\CategoryPeer;
  24: use Thelia\Model\CategoryQuery;
  25: use Thelia\Model\CategoryVersion;
  26: use Thelia\Model\CategoryVersionPeer;
  27: use Thelia\Model\CategoryVersionQuery;
  28: use Thelia\Model\ContentAssoc;
  29: use Thelia\Model\ContentAssocQuery;
  30: use Thelia\Model\Document;
  31: use Thelia\Model\DocumentQuery;
  32: use Thelia\Model\FeatureCategory;
  33: use Thelia\Model\FeatureCategoryQuery;
  34: use Thelia\Model\Image;
  35: use Thelia\Model\ImageQuery;
  36: use Thelia\Model\ProductCategory;
  37: use Thelia\Model\ProductCategoryQuery;
  38: use Thelia\Model\Rewriting;
  39: use Thelia\Model\RewritingQuery;
  40: 
  41: /**
  42:  * Base class that represents a row from the 'category' table.
  43:  *
  44:  *
  45:  *
  46:  * @package    propel.generator.Thelia.Model.om
  47:  */
  48: abstract class BaseCategory extends BaseObject implements Persistent
  49: {
  50:     /**
  51:      * Peer class name
  52:      */
  53:     const PEER = 'Thelia\\Model\\CategoryPeer';
  54: 
  55:     /**
  56:      * The Peer class.
  57:      * Instance provides a convenient way of calling static methods on a class
  58:      * that calling code may not be able to identify.
  59:      * @var        CategoryPeer
  60:      */
  61:     protected static $peer;
  62: 
  63:     /**
  64:      * The flag var to prevent infinit loop in deep copy
  65:      * @var       boolean
  66:      */
  67:     protected $startCopy = false;
  68: 
  69:     /**
  70:      * The value for the id field.
  71:      * @var        int
  72:      */
  73:     protected $id;
  74: 
  75:     /**
  76:      * The value for the parent field.
  77:      * @var        int
  78:      */
  79:     protected $parent;
  80: 
  81:     /**
  82:      * The value for the link field.
  83:      * @var        string
  84:      */
  85:     protected $link;
  86: 
  87:     /**
  88:      * The value for the visible field.
  89:      * @var        int
  90:      */
  91:     protected $visible;
  92: 
  93:     /**
  94:      * The value for the position field.
  95:      * @var        int
  96:      */
  97:     protected $position;
  98: 
  99:     /**
 100:      * The value for the created_at field.
 101:      * @var        string
 102:      */
 103:     protected $created_at;
 104: 
 105:     /**
 106:      * The value for the updated_at field.
 107:      * @var        string
 108:      */
 109:     protected $updated_at;
 110: 
 111:     /**
 112:      * The value for the version field.
 113:      * Note: this column has a database default value of: 0
 114:      * @var        int
 115:      */
 116:     protected $version;
 117: 
 118:     /**
 119:      * The value for the version_created_at field.
 120:      * @var        string
 121:      */
 122:     protected $version_created_at;
 123: 
 124:     /**
 125:      * The value for the version_created_by field.
 126:      * @var        string
 127:      */
 128:     protected $version_created_by;
 129: 
 130:     /**
 131:      * @var        PropelObjectCollection|ProductCategory[] Collection to store aggregation of ProductCategory objects.
 132:      */
 133:     protected $collProductCategorys;
 134:     protected $collProductCategorysPartial;
 135: 
 136:     /**
 137:      * @var        PropelObjectCollection|FeatureCategory[] Collection to store aggregation of FeatureCategory objects.
 138:      */
 139:     protected $collFeatureCategorys;
 140:     protected $collFeatureCategorysPartial;
 141: 
 142:     /**
 143:      * @var        PropelObjectCollection|AttributeCategory[] Collection to store aggregation of AttributeCategory objects.
 144:      */
 145:     protected $collAttributeCategorys;
 146:     protected $collAttributeCategorysPartial;
 147: 
 148:     /**
 149:      * @var        PropelObjectCollection|ContentAssoc[] Collection to store aggregation of ContentAssoc objects.
 150:      */
 151:     protected $collContentAssocs;
 152:     protected $collContentAssocsPartial;
 153: 
 154:     /**
 155:      * @var        PropelObjectCollection|Image[] Collection to store aggregation of Image objects.
 156:      */
 157:     protected $collImages;
 158:     protected $collImagesPartial;
 159: 
 160:     /**
 161:      * @var        PropelObjectCollection|Document[] Collection to store aggregation of Document objects.
 162:      */
 163:     protected $collDocuments;
 164:     protected $collDocumentsPartial;
 165: 
 166:     /**
 167:      * @var        PropelObjectCollection|Rewriting[] Collection to store aggregation of Rewriting objects.
 168:      */
 169:     protected $collRewritings;
 170:     protected $collRewritingsPartial;
 171: 
 172:     /**
 173:      * @var        PropelObjectCollection|CategoryI18n[] Collection to store aggregation of CategoryI18n objects.
 174:      */
 175:     protected $collCategoryI18ns;
 176:     protected $collCategoryI18nsPartial;
 177: 
 178:     /**
 179:      * @var        PropelObjectCollection|CategoryVersion[] Collection to store aggregation of CategoryVersion objects.
 180:      */
 181:     protected $collCategoryVersions;
 182:     protected $collCategoryVersionsPartial;
 183: 
 184:     /**
 185:      * Flag to prevent endless save loop, if this object is referenced
 186:      * by another object which falls in this transaction.
 187:      * @var        boolean
 188:      */
 189:     protected $alreadyInSave = false;
 190: 
 191:     /**
 192:      * Flag to prevent endless validation loop, if this object is referenced
 193:      * by another object which falls in this transaction.
 194:      * @var        boolean
 195:      */
 196:     protected $alreadyInValidation = false;
 197: 
 198:     /**
 199:      * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced
 200:      * @var        boolean
 201:      */
 202:     protected $alreadyInClearAllReferencesDeep = false;
 203: 
 204:     // i18n behavior
 205: 
 206:     /**
 207:      * Current locale
 208:      * @var        string
 209:      */
 210:     protected $currentLocale = 'en_US';
 211: 
 212:     /**
 213:      * Current translation objects
 214:      * @var        array[CategoryI18n]
 215:      */
 216:     protected $currentTranslations;
 217: 
 218:     // versionable behavior
 219: 
 220: 
 221:     /**
 222:      * @var bool
 223:      */
 224:     protected $enforceVersion = false;
 225: 
 226:     /**
 227:      * An array of objects scheduled for deletion.
 228:      * @var     PropelObjectCollection
 229:      */
 230:     protected $productCategorysScheduledForDeletion = null;
 231: 
 232:     /**
 233:      * An array of objects scheduled for deletion.
 234:      * @var     PropelObjectCollection
 235:      */
 236:     protected $featureCategorysScheduledForDeletion = null;
 237: 
 238:     /**
 239:      * An array of objects scheduled for deletion.
 240:      * @var     PropelObjectCollection
 241:      */
 242:     protected $attributeCategorysScheduledForDeletion = null;
 243: 
 244:     /**
 245:      * An array of objects scheduled for deletion.
 246:      * @var     PropelObjectCollection
 247:      */
 248:     protected $contentAssocsScheduledForDeletion = null;
 249: 
 250:     /**
 251:      * An array of objects scheduled for deletion.
 252:      * @var     PropelObjectCollection
 253:      */
 254:     protected $imagesScheduledForDeletion = null;
 255: 
 256:     /**
 257:      * An array of objects scheduled for deletion.
 258:      * @var     PropelObjectCollection
 259:      */
 260:     protected $documentsScheduledForDeletion = null;
 261: 
 262:     /**
 263:      * An array of objects scheduled for deletion.
 264:      * @var     PropelObjectCollection
 265:      */
 266:     protected $rewritingsScheduledForDeletion = null;
 267: 
 268:     /**
 269:      * An array of objects scheduled for deletion.
 270:      * @var     PropelObjectCollection
 271:      */
 272:     protected $categoryI18nsScheduledForDeletion = null;
 273: 
 274:     /**
 275:      * An array of objects scheduled for deletion.
 276:      * @var     PropelObjectCollection
 277:      */
 278:     protected $categoryVersionsScheduledForDeletion = null;
 279: 
 280:     /**
 281:      * Applies default values to this object.
 282:      * This method should be called from the object's constructor (or
 283:      * equivalent initialization method).
 284:      * @see        __construct()
 285:      */
 286:     public function applyDefaultValues()
 287:     {
 288:         $this->version = 0;
 289:     }
 290: 
 291:     /**
 292:      * Initializes internal state of BaseCategory object.
 293:      * @see        applyDefaults()
 294:      */
 295:     public function __construct()
 296:     {
 297:         parent::__construct();
 298:         $this->applyDefaultValues();
 299:     }
 300: 
 301:     /**
 302:      * Get the [id] column value.
 303:      *
 304:      * @return int
 305:      */
 306:     public function getId()
 307:     {
 308:         return $this->id;
 309:     }
 310: 
 311:     /**
 312:      * Get the [parent] column value.
 313:      *
 314:      * @return int
 315:      */
 316:     public function getParent()
 317:     {
 318:         return $this->parent;
 319:     }
 320: 
 321:     /**
 322:      * Get the [link] column value.
 323:      *
 324:      * @return string
 325:      */
 326:     public function getLink()
 327:     {
 328:         return $this->link;
 329:     }
 330: 
 331:     /**
 332:      * Get the [visible] column value.
 333:      *
 334:      * @return int
 335:      */
 336:     public function getVisible()
 337:     {
 338:         return $this->visible;
 339:     }
 340: 
 341:     /**
 342:      * Get the [position] column value.
 343:      *
 344:      * @return int
 345:      */
 346:     public function getPosition()
 347:     {
 348:         return $this->position;
 349:     }
 350: 
 351:     /**
 352:      * Get the [optionally formatted] temporal [created_at] column value.
 353:      *
 354:      *
 355:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 356:      *               If format is null, then the raw DateTime object will be returned.
 357:      * @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
 358:      * @throws PropelException - if unable to parse/validate the date/time value.
 359:      */
 360:     public function getCreatedAt($format = 'Y-m-d H:i:s')
 361:     {
 362:         if ($this->created_at === null) {
 363:             return null;
 364:         }
 365: 
 366:         if ($this->created_at === '0000-00-00 00:00:00') {
 367:             // while technically this is not a default value of null,
 368:             // this seems to be closest in meaning.
 369:             return null;
 370:         }
 371: 
 372:         try {
 373:             $dt = new DateTime($this->created_at);
 374:         } catch (Exception $x) {
 375:             throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
 376:         }
 377: 
 378:         if ($format === null) {
 379:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 380:             return $dt;
 381:         }
 382: 
 383:         if (strpos($format, '%') !== false) {
 384:             return strftime($format, $dt->format('U'));
 385:         }
 386: 
 387:         return $dt->format($format);
 388: 
 389:     }
 390: 
 391:     /**
 392:      * Get the [optionally formatted] temporal [updated_at] column value.
 393:      *
 394:      *
 395:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 396:      *               If format is null, then the raw DateTime object will be returned.
 397:      * @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
 398:      * @throws PropelException - if unable to parse/validate the date/time value.
 399:      */
 400:     public function getUpdatedAt($format = 'Y-m-d H:i:s')
 401:     {
 402:         if ($this->updated_at === null) {
 403:             return null;
 404:         }
 405: 
 406:         if ($this->updated_at === '0000-00-00 00:00:00') {
 407:             // while technically this is not a default value of null,
 408:             // this seems to be closest in meaning.
 409:             return null;
 410:         }
 411: 
 412:         try {
 413:             $dt = new DateTime($this->updated_at);
 414:         } catch (Exception $x) {
 415:             throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
 416:         }
 417: 
 418:         if ($format === null) {
 419:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 420:             return $dt;
 421:         }
 422: 
 423:         if (strpos($format, '%') !== false) {
 424:             return strftime($format, $dt->format('U'));
 425:         }
 426: 
 427:         return $dt->format($format);
 428: 
 429:     }
 430: 
 431:     /**
 432:      * Get the [version] column value.
 433:      *
 434:      * @return int
 435:      */
 436:     public function getVersion()
 437:     {
 438:         return $this->version;
 439:     }
 440: 
 441:     /**
 442:      * Get the [optionally formatted] temporal [version_created_at] column value.
 443:      *
 444:      *
 445:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 446:      *               If format is null, then the raw DateTime object will be returned.
 447:      * @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
 448:      * @throws PropelException - if unable to parse/validate the date/time value.
 449:      */
 450:     public function getVersionCreatedAt($format = 'Y-m-d H:i:s')
 451:     {
 452:         if ($this->version_created_at === null) {
 453:             return null;
 454:         }
 455: 
 456:         if ($this->version_created_at === '0000-00-00 00:00:00') {
 457:             // while technically this is not a default value of null,
 458:             // this seems to be closest in meaning.
 459:             return null;
 460:         }
 461: 
 462:         try {
 463:             $dt = new DateTime($this->version_created_at);
 464:         } catch (Exception $x) {
 465:             throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
 466:         }
 467: 
 468:         if ($format === null) {
 469:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 470:             return $dt;
 471:         }
 472: 
 473:         if (strpos($format, '%') !== false) {
 474:             return strftime($format, $dt->format('U'));
 475:         }
 476: 
 477:         return $dt->format($format);
 478: 
 479:     }
 480: 
 481:     /**
 482:      * Get the [version_created_by] column value.
 483:      *
 484:      * @return string
 485:      */
 486:     public function getVersionCreatedBy()
 487:     {
 488:         return $this->version_created_by;
 489:     }
 490: 
 491:     /**
 492:      * Set the value of [id] column.
 493:      *
 494:      * @param int $v new value
 495:      * @return Category The current object (for fluent API support)
 496:      */
 497:     public function setId($v)
 498:     {
 499:         if ($v !== null && is_numeric($v)) {
 500:             $v = (int) $v;
 501:         }
 502: 
 503:         if ($this->id !== $v) {
 504:             $this->id = $v;
 505:             $this->modifiedColumns[] = CategoryPeer::ID;
 506:         }
 507: 
 508: 
 509:         return $this;
 510:     } // setId()
 511: 
 512:     /**
 513:      * Set the value of [parent] column.
 514:      *
 515:      * @param int $v new value
 516:      * @return Category The current object (for fluent API support)
 517:      */
 518:     public function setParent($v)
 519:     {
 520:         if ($v !== null && is_numeric($v)) {
 521:             $v = (int) $v;
 522:         }
 523: 
 524:         if ($this->parent !== $v) {
 525:             $this->parent = $v;
 526:             $this->modifiedColumns[] = CategoryPeer::PARENT;
 527:         }
 528: 
 529: 
 530:         return $this;
 531:     } // setParent()
 532: 
 533:     /**
 534:      * Set the value of [link] column.
 535:      *
 536:      * @param string $v new value
 537:      * @return Category The current object (for fluent API support)
 538:      */
 539:     public function setLink($v)
 540:     {
 541:         if ($v !== null && is_numeric($v)) {
 542:             $v = (string) $v;
 543:         }
 544: 
 545:         if ($this->link !== $v) {
 546:             $this->link = $v;
 547:             $this->modifiedColumns[] = CategoryPeer::LINK;
 548:         }
 549: 
 550: 
 551:         return $this;
 552:     } // setLink()
 553: 
 554:     /**
 555:      * Set the value of [visible] column.
 556:      *
 557:      * @param int $v new value
 558:      * @return Category The current object (for fluent API support)
 559:      */
 560:     public function setVisible($v)
 561:     {
 562:         if ($v !== null && is_numeric($v)) {
 563:             $v = (int) $v;
 564:         }
 565: 
 566:         if ($this->visible !== $v) {
 567:             $this->visible = $v;
 568:             $this->modifiedColumns[] = CategoryPeer::VISIBLE;
 569:         }
 570: 
 571: 
 572:         return $this;
 573:     } // setVisible()
 574: 
 575:     /**
 576:      * Set the value of [position] column.
 577:      *
 578:      * @param int $v new value
 579:      * @return Category The current object (for fluent API support)
 580:      */
 581:     public function setPosition($v)
 582:     {
 583:         if ($v !== null && is_numeric($v)) {
 584:             $v = (int) $v;
 585:         }
 586: 
 587:         if ($this->position !== $v) {
 588:             $this->position = $v;
 589:             $this->modifiedColumns[] = CategoryPeer::POSITION;
 590:         }
 591: 
 592: 
 593:         return $this;
 594:     } // setPosition()
 595: 
 596:     /**
 597:      * Sets the value of [created_at] column to a normalized version of the date/time value specified.
 598:      *
 599:      * @param mixed $v string, integer (timestamp), or DateTime value.
 600:      *               Empty strings are treated as null.
 601:      * @return Category The current object (for fluent API support)
 602:      */
 603:     public function setCreatedAt($v)
 604:     {
 605:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 606:         if ($this->created_at !== null || $dt !== null) {
 607:             $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 608:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 609:             if ($currentDateAsString !== $newDateAsString) {
 610:                 $this->created_at = $newDateAsString;
 611:                 $this->modifiedColumns[] = CategoryPeer::CREATED_AT;
 612:             }
 613:         } // if either are not null
 614: 
 615: 
 616:         return $this;
 617:     } // setCreatedAt()
 618: 
 619:     /**
 620:      * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
 621:      *
 622:      * @param mixed $v string, integer (timestamp), or DateTime value.
 623:      *               Empty strings are treated as null.
 624:      * @return Category The current object (for fluent API support)
 625:      */
 626:     public function setUpdatedAt($v)
 627:     {
 628:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 629:         if ($this->updated_at !== null || $dt !== null) {
 630:             $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 631:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 632:             if ($currentDateAsString !== $newDateAsString) {
 633:                 $this->updated_at = $newDateAsString;
 634:                 $this->modifiedColumns[] = CategoryPeer::UPDATED_AT;
 635:             }
 636:         } // if either are not null
 637: 
 638: 
 639:         return $this;
 640:     } // setUpdatedAt()
 641: 
 642:     /**
 643:      * Set the value of [version] column.
 644:      *
 645:      * @param int $v new value
 646:      * @return Category The current object (for fluent API support)
 647:      */
 648:     public function setVersion($v)
 649:     {
 650:         if ($v !== null && is_numeric($v)) {
 651:             $v = (int) $v;
 652:         }
 653: 
 654:         if ($this->version !== $v) {
 655:             $this->version = $v;
 656:             $this->modifiedColumns[] = CategoryPeer::VERSION;
 657:         }
 658: 
 659: 
 660:         return $this;
 661:     } // setVersion()
 662: 
 663:     /**
 664:      * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
 665:      *
 666:      * @param mixed $v string, integer (timestamp), or DateTime value.
 667:      *               Empty strings are treated as null.
 668:      * @return Category The current object (for fluent API support)
 669:      */
 670:     public function setVersionCreatedAt($v)
 671:     {
 672:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 673:         if ($this->version_created_at !== null || $dt !== null) {
 674:             $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 675:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 676:             if ($currentDateAsString !== $newDateAsString) {
 677:                 $this->version_created_at = $newDateAsString;
 678:                 $this->modifiedColumns[] = CategoryPeer::VERSION_CREATED_AT;
 679:             }
 680:         } // if either are not null
 681: 
 682: 
 683:         return $this;
 684:     } // setVersionCreatedAt()
 685: 
 686:     /**
 687:      * Set the value of [version_created_by] column.
 688:      *
 689:      * @param string $v new value
 690:      * @return Category The current object (for fluent API support)
 691:      */
 692:     public function setVersionCreatedBy($v)
 693:     {
 694:         if ($v !== null && is_numeric($v)) {
 695:             $v = (string) $v;
 696:         }
 697: 
 698:         if ($this->version_created_by !== $v) {
 699:             $this->version_created_by = $v;
 700:             $this->modifiedColumns[] = CategoryPeer::VERSION_CREATED_BY;
 701:         }
 702: 
 703: 
 704:         return $this;
 705:     } // setVersionCreatedBy()
 706: 
 707:     /**
 708:      * Indicates whether the columns in this object are only set to default values.
 709:      *
 710:      * This method can be used in conjunction with isModified() to indicate whether an object is both
 711:      * modified _and_ has some values set which are non-default.
 712:      *
 713:      * @return boolean Whether the columns in this object are only been set with default values.
 714:      */
 715:     public function hasOnlyDefaultValues()
 716:     {
 717:             if ($this->version !== 0) {
 718:                 return false;
 719:             }
 720: 
 721:         // otherwise, everything was equal, so return true
 722:         return true;
 723:     } // hasOnlyDefaultValues()
 724: 
 725:     /**
 726:      * Hydrates (populates) the object variables with values from the database resultset.
 727:      *
 728:      * An offset (0-based "start column") is specified so that objects can be hydrated
 729:      * with a subset of the columns in the resultset rows.  This is needed, for example,
 730:      * for results of JOIN queries where the resultset row includes columns from two or
 731:      * more tables.
 732:      *
 733:      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
 734:      * @param int $startcol 0-based offset column which indicates which restultset column to start with.
 735:      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
 736:      * @return int             next starting column
 737:      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
 738:      */
 739:     public function hydrate($row, $startcol = 0, $rehydrate = false)
 740:     {
 741:         try {
 742: 
 743:             $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
 744:             $this->parent = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
 745:             $this->link = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
 746:             $this->visible = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
 747:             $this->position = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
 748:             $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
 749:             $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
 750:             $this->version = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
 751:             $this->version_created_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
 752:             $this->version_created_by = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
 753:             $this->resetModified();
 754: 
 755:             $this->setNew(false);
 756: 
 757:             if ($rehydrate) {
 758:                 $this->ensureConsistency();
 759:             }
 760:             $this->postHydrate($row, $startcol, $rehydrate);
 761:             return $startcol + 10; // 10 = CategoryPeer::NUM_HYDRATE_COLUMNS.
 762: 
 763:         } catch (Exception $e) {
 764:             throw new PropelException("Error populating Category object", $e);
 765:         }
 766:     }
 767: 
 768:     /**
 769:      * Checks and repairs the internal consistency of the object.
 770:      *
 771:      * This method is executed after an already-instantiated object is re-hydrated
 772:      * from the database.  It exists to check any foreign keys to make sure that
 773:      * the objects related to the current object are correct based on foreign key.
 774:      *
 775:      * You can override this method in the stub class, but you should always invoke
 776:      * the base method from the overridden method (i.e. parent::ensureConsistency()),
 777:      * in case your model changes.
 778:      *
 779:      * @throws PropelException
 780:      */
 781:     public function ensureConsistency()
 782:     {
 783: 
 784:     } // ensureConsistency
 785: 
 786:     /**
 787:      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
 788:      *
 789:      * This will only work if the object has been saved and has a valid primary key set.
 790:      *
 791:      * @param boolean $deep (optional) Whether to also de-associated any related objects.
 792:      * @param PropelPDO $con (optional) The PropelPDO connection to use.
 793:      * @return void
 794:      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
 795:      */
 796:     public function reload($deep = false, PropelPDO $con = null)
 797:     {
 798:         if ($this->isDeleted()) {
 799:             throw new PropelException("Cannot reload a deleted object.");
 800:         }
 801: 
 802:         if ($this->isNew()) {
 803:             throw new PropelException("Cannot reload an unsaved object.");
 804:         }
 805: 
 806:         if ($con === null) {
 807:             $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
 808:         }
 809: 
 810:         // We don't need to alter the object instance pool; we're just modifying this instance
 811:         // already in the pool.
 812: 
 813:         $stmt = CategoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
 814:         $row = $stmt->fetch(PDO::FETCH_NUM);
 815:         $stmt->closeCursor();
 816:         if (!$row) {
 817:             throw new PropelException('Cannot find matching row in the database to reload object values.');
 818:         }
 819:         $this->hydrate($row, 0, true); // rehydrate
 820: 
 821:         if ($deep) {  // also de-associate any related objects?
 822: 
 823:             $this->collProductCategorys = null;
 824: 
 825:             $this->collFeatureCategorys = null;
 826: 
 827:             $this->collAttributeCategorys = null;
 828: 
 829:             $this->collContentAssocs = null;
 830: 
 831:             $this->collImages = null;
 832: 
 833:             $this->collDocuments = null;
 834: 
 835:             $this->collRewritings = null;
 836: 
 837:             $this->collCategoryI18ns = null;
 838: 
 839:             $this->collCategoryVersions = null;
 840: 
 841:         } // if (deep)
 842:     }
 843: 
 844:     /**
 845:      * Removes this object from datastore and sets delete attribute.
 846:      *
 847:      * @param PropelPDO $con
 848:      * @return void
 849:      * @throws PropelException
 850:      * @throws Exception
 851:      * @see        BaseObject::setDeleted()
 852:      * @see        BaseObject::isDeleted()
 853:      */
 854:     public function delete(PropelPDO $con = null)
 855:     {
 856:         if ($this->isDeleted()) {
 857:             throw new PropelException("This object has already been deleted.");
 858:         }
 859: 
 860:         if ($con === null) {
 861:             $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 862:         }
 863: 
 864:         $con->beginTransaction();
 865:         try {
 866:             $deleteQuery = CategoryQuery::create()
 867:                 ->filterByPrimaryKey($this->getPrimaryKey());
 868:             $ret = $this->preDelete($con);
 869:             if ($ret) {
 870:                 $deleteQuery->delete($con);
 871:                 $this->postDelete($con);
 872:                 $con->commit();
 873:                 $this->setDeleted(true);
 874:             } else {
 875:                 $con->commit();
 876:             }
 877:         } catch (Exception $e) {
 878:             $con->rollBack();
 879:             throw $e;
 880:         }
 881:     }
 882: 
 883:     /**
 884:      * Persists this object to the database.
 885:      *
 886:      * If the object is new, it inserts it; otherwise an update is performed.
 887:      * All modified related objects will also be persisted in the doSave()
 888:      * method.  This method wraps all precipitate database operations in a
 889:      * single transaction.
 890:      *
 891:      * @param PropelPDO $con
 892:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 893:      * @throws PropelException
 894:      * @throws Exception
 895:      * @see        doSave()
 896:      */
 897:     public function save(PropelPDO $con = null)
 898:     {
 899:         if ($this->isDeleted()) {
 900:             throw new PropelException("You cannot save an object that has been deleted.");
 901:         }
 902: 
 903:         if ($con === null) {
 904:             $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 905:         }
 906: 
 907:         $con->beginTransaction();
 908:         $isInsert = $this->isNew();
 909:         try {
 910:             $ret = $this->preSave($con);
 911:             // versionable behavior
 912:             if ($this->isVersioningNecessary()) {
 913:                 $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
 914:                 if (!$this->isColumnModified(CategoryPeer::VERSION_CREATED_AT)) {
 915:                     $this->setVersionCreatedAt(time());
 916:                 }
 917:                 $createVersion = true; // for postSave hook
 918:             }
 919:             if ($isInsert) {
 920:                 $ret = $ret && $this->preInsert($con);
 921:                 // timestampable behavior
 922:                 if (!$this->isColumnModified(CategoryPeer::CREATED_AT)) {
 923:                     $this->setCreatedAt(time());
 924:                 }
 925:                 if (!$this->isColumnModified(CategoryPeer::UPDATED_AT)) {
 926:                     $this->setUpdatedAt(time());
 927:                 }
 928:             } else {
 929:                 $ret = $ret && $this->preUpdate($con);
 930:                 // timestampable behavior
 931:                 if ($this->isModified() && !$this->isColumnModified(CategoryPeer::UPDATED_AT)) {
 932:                     $this->setUpdatedAt(time());
 933:                 }
 934:             }
 935:             if ($ret) {
 936:                 $affectedRows = $this->doSave($con);
 937:                 if ($isInsert) {
 938:                     $this->postInsert($con);
 939:                 } else {
 940:                     $this->postUpdate($con);
 941:                 }
 942:                 $this->postSave($con);
 943:                 // versionable behavior
 944:                 if (isset($createVersion)) {
 945:                     $this->addVersion($con);
 946:                 }
 947:                 CategoryPeer::addInstanceToPool($this);
 948:             } else {
 949:                 $affectedRows = 0;
 950:             }
 951:             $con->commit();
 952: 
 953:             return $affectedRows;
 954:         } catch (Exception $e) {
 955:             $con->rollBack();
 956:             throw $e;
 957:         }
 958:     }
 959: 
 960:     /**
 961:      * Performs the work of inserting or updating the row in the database.
 962:      *
 963:      * If the object is new, it inserts it; otherwise an update is performed.
 964:      * All related objects are also updated in this method.
 965:      *
 966:      * @param PropelPDO $con
 967:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 968:      * @throws PropelException
 969:      * @see        save()
 970:      */
 971:     protected function doSave(PropelPDO $con)
 972:     {
 973:         $affectedRows = 0; // initialize var to track total num of affected rows
 974:         if (!$this->alreadyInSave) {
 975:             $this->alreadyInSave = true;
 976: 
 977:             if ($this->isNew() || $this->isModified()) {
 978:                 // persist changes
 979:                 if ($this->isNew()) {
 980:                     $this->doInsert($con);
 981:                 } else {
 982:                     $this->doUpdate($con);
 983:                 }
 984:                 $affectedRows += 1;
 985:                 $this->resetModified();
 986:             }
 987: 
 988:             if ($this->productCategorysScheduledForDeletion !== null) {
 989:                 if (!$this->productCategorysScheduledForDeletion->isEmpty()) {
 990:                     ProductCategoryQuery::create()
 991:                         ->filterByPrimaryKeys($this->productCategorysScheduledForDeletion->getPrimaryKeys(false))
 992:                         ->delete($con);
 993:                     $this->productCategorysScheduledForDeletion = null;
 994:                 }
 995:             }
 996: 
 997:             if ($this->collProductCategorys !== null) {
 998:                 foreach ($this->collProductCategorys as $referrerFK) {
 999:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1000:                         $affectedRows += $referrerFK->save($con);
1001:                     }
1002:                 }
1003:             }
1004: 
1005:             if ($this->featureCategorysScheduledForDeletion !== null) {
1006:                 if (!$this->featureCategorysScheduledForDeletion->isEmpty()) {
1007:                     FeatureCategoryQuery::create()
1008:                         ->filterByPrimaryKeys($this->featureCategorysScheduledForDeletion->getPrimaryKeys(false))
1009:                         ->delete($con);
1010:                     $this->featureCategorysScheduledForDeletion = null;
1011:                 }
1012:             }
1013: 
1014:             if ($this->collFeatureCategorys !== null) {
1015:                 foreach ($this->collFeatureCategorys as $referrerFK) {
1016:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1017:                         $affectedRows += $referrerFK->save($con);
1018:                     }
1019:                 }
1020:             }
1021: 
1022:             if ($this->attributeCategorysScheduledForDeletion !== null) {
1023:                 if (!$this->attributeCategorysScheduledForDeletion->isEmpty()) {
1024:                     AttributeCategoryQuery::create()
1025:                         ->filterByPrimaryKeys($this->attributeCategorysScheduledForDeletion->getPrimaryKeys(false))
1026:                         ->delete($con);
1027:                     $this->attributeCategorysScheduledForDeletion = null;
1028:                 }
1029:             }
1030: 
1031:             if ($this->collAttributeCategorys !== null) {
1032:                 foreach ($this->collAttributeCategorys as $referrerFK) {
1033:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1034:                         $affectedRows += $referrerFK->save($con);
1035:                     }
1036:                 }
1037:             }
1038: 
1039:             if ($this->contentAssocsScheduledForDeletion !== null) {
1040:                 if (!$this->contentAssocsScheduledForDeletion->isEmpty()) {
1041:                     foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) {
1042:                         // need to save related object because we set the relation to null
1043:                         $contentAssoc->save($con);
1044:                     }
1045:                     $this->contentAssocsScheduledForDeletion = null;
1046:                 }
1047:             }
1048: 
1049:             if ($this->collContentAssocs !== null) {
1050:                 foreach ($this->collContentAssocs as $referrerFK) {
1051:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1052:                         $affectedRows += $referrerFK->save($con);
1053:                     }
1054:                 }
1055:             }
1056: 
1057:             if ($this->imagesScheduledForDeletion !== null) {
1058:                 if (!$this->imagesScheduledForDeletion->isEmpty()) {
1059:                     foreach ($this->imagesScheduledForDeletion as $image) {
1060:                         // need to save related object because we set the relation to null
1061:                         $image->save($con);
1062:                     }
1063:                     $this->imagesScheduledForDeletion = null;
1064:                 }
1065:             }
1066: 
1067:             if ($this->collImages !== null) {
1068:                 foreach ($this->collImages as $referrerFK) {
1069:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1070:                         $affectedRows += $referrerFK->save($con);
1071:                     }
1072:                 }
1073:             }
1074: 
1075:             if ($this->documentsScheduledForDeletion !== null) {
1076:                 if (!$this->documentsScheduledForDeletion->isEmpty()) {
1077:                     foreach ($this->documentsScheduledForDeletion as $document) {
1078:                         // need to save related object because we set the relation to null
1079:                         $document->save($con);
1080:                     }
1081:                     $this->documentsScheduledForDeletion = null;
1082:                 }
1083:             }
1084: 
1085:             if ($this->collDocuments !== null) {
1086:                 foreach ($this->collDocuments as $referrerFK) {
1087:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1088:                         $affectedRows += $referrerFK->save($con);
1089:                     }
1090:                 }
1091:             }
1092: 
1093:             if ($this->rewritingsScheduledForDeletion !== null) {
1094:                 if (!$this->rewritingsScheduledForDeletion->isEmpty()) {
1095:                     foreach ($this->rewritingsScheduledForDeletion as $rewriting) {
1096:                         // need to save related object because we set the relation to null
1097:                         $rewriting->save($con);
1098:                     }
1099:                     $this->rewritingsScheduledForDeletion = null;
1100:                 }
1101:             }
1102: 
1103:             if ($this->collRewritings !== null) {
1104:                 foreach ($this->collRewritings as $referrerFK) {
1105:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1106:                         $affectedRows += $referrerFK->save($con);
1107:                     }
1108:                 }
1109:             }
1110: 
1111:             if ($this->categoryI18nsScheduledForDeletion !== null) {
1112:                 if (!$this->categoryI18nsScheduledForDeletion->isEmpty()) {
1113:                     CategoryI18nQuery::create()
1114:                         ->filterByPrimaryKeys($this->categoryI18nsScheduledForDeletion->getPrimaryKeys(false))
1115:                         ->delete($con);
1116:                     $this->categoryI18nsScheduledForDeletion = null;
1117:                 }
1118:             }
1119: 
1120:             if ($this->collCategoryI18ns !== null) {
1121:                 foreach ($this->collCategoryI18ns as $referrerFK) {
1122:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1123:                         $affectedRows += $referrerFK->save($con);
1124:                     }
1125:                 }
1126:             }
1127: 
1128:             if ($this->categoryVersionsScheduledForDeletion !== null) {
1129:                 if (!$this->categoryVersionsScheduledForDeletion->isEmpty()) {
1130:                     CategoryVersionQuery::create()
1131:                         ->filterByPrimaryKeys($this->categoryVersionsScheduledForDeletion->getPrimaryKeys(false))
1132:                         ->delete($con);
1133:                     $this->categoryVersionsScheduledForDeletion = null;
1134:                 }
1135:             }
1136: 
1137:             if ($this->collCategoryVersions !== null) {
1138:                 foreach ($this->collCategoryVersions as $referrerFK) {
1139:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
1140:                         $affectedRows += $referrerFK->save($con);
1141:                     }
1142:                 }
1143:             }
1144: 
1145:             $this->alreadyInSave = false;
1146: 
1147:         }
1148: 
1149:         return $affectedRows;
1150:     } // doSave()
1151: 
1152:     /**
1153:      * Insert the row in the database.
1154:      *
1155:      * @param PropelPDO $con
1156:      *
1157:      * @throws PropelException
1158:      * @see        doSave()
1159:      */
1160:     protected function doInsert(PropelPDO $con)
1161:     {
1162:         $modifiedColumns = array();
1163:         $index = 0;
1164: 
1165:         $this->modifiedColumns[] = CategoryPeer::ID;
1166:         if (null !== $this->id) {
1167:             throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryPeer::ID . ')');
1168:         }
1169: 
1170:          // check the columns in natural order for more readable SQL queries
1171:         if ($this->isColumnModified(CategoryPeer::ID)) {
1172:             $modifiedColumns[':p' . $index++]  = '`id`';
1173:         }
1174:         if ($this->isColumnModified(CategoryPeer::PARENT)) {
1175:             $modifiedColumns[':p' . $index++]  = '`parent`';
1176:         }
1177:         if ($this->isColumnModified(CategoryPeer::LINK)) {
1178:             $modifiedColumns[':p' . $index++]  = '`link`';
1179:         }
1180:         if ($this->isColumnModified(CategoryPeer::VISIBLE)) {
1181:             $modifiedColumns[':p' . $index++]  = '`visible`';
1182:         }
1183:         if ($this->isColumnModified(CategoryPeer::POSITION)) {
1184:             $modifiedColumns[':p' . $index++]  = '`position`';
1185:         }
1186:         if ($this->isColumnModified(CategoryPeer::CREATED_AT)) {
1187:             $modifiedColumns[':p' . $index++]  = '`created_at`';
1188:         }
1189:         if ($this->isColumnModified(CategoryPeer::UPDATED_AT)) {
1190:             $modifiedColumns[':p' . $index++]  = '`updated_at`';
1191:         }
1192:         if ($this->isColumnModified(CategoryPeer::VERSION)) {
1193:             $modifiedColumns[':p' . $index++]  = '`version`';
1194:         }
1195:         if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_AT)) {
1196:             $modifiedColumns[':p' . $index++]  = '`version_created_at`';
1197:         }
1198:         if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_BY)) {
1199:             $modifiedColumns[':p' . $index++]  = '`version_created_by`';
1200:         }
1201: 
1202:         $sql = sprintf(
1203:             'INSERT INTO `category` (%s) VALUES (%s)',
1204:             implode(', ', $modifiedColumns),
1205:             implode(', ', array_keys($modifiedColumns))
1206:         );
1207: 
1208:         try {
1209:             $stmt = $con->prepare($sql);
1210:             foreach ($modifiedColumns as $identifier => $columnName) {
1211:                 switch ($columnName) {
1212:                     case '`id`':
1213:                         $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
1214:                         break;
1215:                     case '`parent`':
1216:                         $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT);
1217:                         break;
1218:                     case '`link`':
1219:                         $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR);
1220:                         break;
1221:                     case '`visible`':
1222:                         $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
1223:                         break;
1224:                     case '`position`':
1225:                         $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
1226:                         break;
1227:                     case '`created_at`':
1228:                         $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
1229:                         break;
1230:                     case '`updated_at`':
1231:                         $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
1232:                         break;
1233:                     case '`version`':
1234:                         $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
1235:                         break;
1236:                     case '`version_created_at`':
1237:                         $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
1238:                         break;
1239:                     case '`version_created_by`':
1240:                         $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
1241:                         break;
1242:                 }
1243:             }
1244:             $stmt->execute();
1245:         } catch (Exception $e) {
1246:             Propel::log($e->getMessage(), Propel::LOG_ERR);
1247:             throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
1248:         }
1249: 
1250:         try {
1251:             $pk = $con->lastInsertId();
1252:         } catch (Exception $e) {
1253:             throw new PropelException('Unable to get autoincrement id.', $e);
1254:         }
1255:         $this->setId($pk);
1256: 
1257:         $this->setNew(false);
1258:     }
1259: 
1260:     /**
1261:      * Update the row in the database.
1262:      *
1263:      * @param PropelPDO $con
1264:      *
1265:      * @see        doSave()
1266:      */
1267:     protected function doUpdate(PropelPDO $con)
1268:     {
1269:         $selectCriteria = $this->buildPkeyCriteria();
1270:         $valuesCriteria = $this->buildCriteria();
1271:         BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
1272:     }
1273: 
1274:     /**
1275:      * Array of ValidationFailed objects.
1276:      * @var        array ValidationFailed[]
1277:      */
1278:     protected $validationFailures = array();
1279: 
1280:     /**
1281:      * Gets any ValidationFailed objects that resulted from last call to validate().
1282:      *
1283:      *
1284:      * @return array ValidationFailed[]
1285:      * @see        validate()
1286:      */
1287:     public function getValidationFailures()
1288:     {
1289:         return $this->validationFailures;
1290:     }
1291: 
1292:     /**
1293:      * Validates the objects modified field values and all objects related to this table.
1294:      *
1295:      * If $columns is either a column name or an array of column names
1296:      * only those columns are validated.
1297:      *
1298:      * @param mixed $columns Column name or an array of column names.
1299:      * @return boolean Whether all columns pass validation.
1300:      * @see        doValidate()
1301:      * @see        getValidationFailures()
1302:      */
1303:     public function validate($columns = null)
1304:     {
1305:         $res = $this->doValidate($columns);
1306:         if ($res === true) {
1307:             $this->validationFailures = array();
1308: 
1309:             return true;
1310:         }
1311: 
1312:         $this->validationFailures = $res;
1313: 
1314:         return false;
1315:     }
1316: 
1317:     /**
1318:      * This function performs the validation work for complex object models.
1319:      *
1320:      * In addition to checking the current object, all related objects will
1321:      * also be validated.  If all pass then <code>true</code> is returned; otherwise
1322:      * an aggreagated array of ValidationFailed objects will be returned.
1323:      *
1324:      * @param array $columns Array of column names to validate.
1325:      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
1326:      */
1327:     protected function doValidate($columns = null)
1328:     {
1329:         if (!$this->alreadyInValidation) {
1330:             $this->alreadyInValidation = true;
1331:             $retval = null;
1332: 
1333:             $failureMap = array();
1334: 
1335: 
1336:             if (($retval = CategoryPeer::doValidate($this, $columns)) !== true) {
1337:                 $failureMap = array_merge($failureMap, $retval);
1338:             }
1339: 
1340: 
1341:                 if ($this->collProductCategorys !== null) {
1342:                     foreach ($this->collProductCategorys as $referrerFK) {
1343:                         if (!$referrerFK->validate($columns)) {
1344:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1345:                         }
1346:                     }
1347:                 }
1348: 
1349:                 if ($this->collFeatureCategorys !== null) {
1350:                     foreach ($this->collFeatureCategorys as $referrerFK) {
1351:                         if (!$referrerFK->validate($columns)) {
1352:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1353:                         }
1354:                     }
1355:                 }
1356: 
1357:                 if ($this->collAttributeCategorys !== null) {
1358:                     foreach ($this->collAttributeCategorys as $referrerFK) {
1359:                         if (!$referrerFK->validate($columns)) {
1360:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1361:                         }
1362:                     }
1363:                 }
1364: 
1365:                 if ($this->collContentAssocs !== null) {
1366:                     foreach ($this->collContentAssocs as $referrerFK) {
1367:                         if (!$referrerFK->validate($columns)) {
1368:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1369:                         }
1370:                     }
1371:                 }
1372: 
1373:                 if ($this->collImages !== null) {
1374:                     foreach ($this->collImages as $referrerFK) {
1375:                         if (!$referrerFK->validate($columns)) {
1376:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1377:                         }
1378:                     }
1379:                 }
1380: 
1381:                 if ($this->collDocuments !== null) {
1382:                     foreach ($this->collDocuments as $referrerFK) {
1383:                         if (!$referrerFK->validate($columns)) {
1384:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1385:                         }
1386:                     }
1387:                 }
1388: 
1389:                 if ($this->collRewritings !== null) {
1390:                     foreach ($this->collRewritings as $referrerFK) {
1391:                         if (!$referrerFK->validate($columns)) {
1392:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1393:                         }
1394:                     }
1395:                 }
1396: 
1397:                 if ($this->collCategoryI18ns !== null) {
1398:                     foreach ($this->collCategoryI18ns as $referrerFK) {
1399:                         if (!$referrerFK->validate($columns)) {
1400:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1401:                         }
1402:                     }
1403:                 }
1404: 
1405:                 if ($this->collCategoryVersions !== null) {
1406:                     foreach ($this->collCategoryVersions as $referrerFK) {
1407:                         if (!$referrerFK->validate($columns)) {
1408:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1409:                         }
1410:                     }
1411:                 }
1412: 
1413: 
1414:             $this->alreadyInValidation = false;
1415:         }
1416: 
1417:         return (!empty($failureMap) ? $failureMap : true);
1418:     }
1419: 
1420:     /**
1421:      * Retrieves a field from the object by name passed in as a string.
1422:      *
1423:      * @param string $name name
1424:      * @param string $type The type of fieldname the $name is of:
1425:      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
1426:      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1427:      *               Defaults to BasePeer::TYPE_PHPNAME
1428:      * @return mixed Value of field.
1429:      */
1430:     public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
1431:     {
1432:         $pos = CategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1433:         $field = $this->getByPosition($pos);
1434: 
1435:         return $field;
1436:     }
1437: 
1438:     /**
1439:      * Retrieves a field from the object by Position as specified in the xml schema.
1440:      * Zero-based.
1441:      *
1442:      * @param int $pos position in xml schema
1443:      * @return mixed Value of field at $pos
1444:      */
1445:     public function getByPosition($pos)
1446:     {
1447:         switch ($pos) {
1448:             case 0:
1449:                 return $this->getId();
1450:                 break;
1451:             case 1:
1452:                 return $this->getParent();
1453:                 break;
1454:             case 2:
1455:                 return $this->getLink();
1456:                 break;
1457:             case 3:
1458:                 return $this->getVisible();
1459:                 break;
1460:             case 4:
1461:                 return $this->getPosition();
1462:                 break;
1463:             case 5:
1464:                 return $this->getCreatedAt();
1465:                 break;
1466:             case 6:
1467:                 return $this->getUpdatedAt();
1468:                 break;
1469:             case 7:
1470:                 return $this->getVersion();
1471:                 break;
1472:             case 8:
1473:                 return $this->getVersionCreatedAt();
1474:                 break;
1475:             case 9:
1476:                 return $this->getVersionCreatedBy();
1477:                 break;
1478:             default:
1479:                 return null;
1480:                 break;
1481:         } // switch()
1482:     }
1483: 
1484:     /**
1485:      * Exports the object as an array.
1486:      *
1487:      * You can specify the key type of the array by passing one of the class
1488:      * type constants.
1489:      *
1490:      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1491:      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1492:      *                    Defaults to BasePeer::TYPE_PHPNAME.
1493:      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
1494:      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
1495:      * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
1496:      *
1497:      * @return array an associative array containing the field names (as keys) and field values
1498:      */
1499:     public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
1500:     {
1501:         if (isset($alreadyDumpedObjects['Category'][$this->getPrimaryKey()])) {
1502:             return '*RECURSION*';
1503:         }
1504:         $alreadyDumpedObjects['Category'][$this->getPrimaryKey()] = true;
1505:         $keys = CategoryPeer::getFieldNames($keyType);
1506:         $result = array(
1507:             $keys[0] => $this->getId(),
1508:             $keys[1] => $this->getParent(),
1509:             $keys[2] => $this->getLink(),
1510:             $keys[3] => $this->getVisible(),
1511:             $keys[4] => $this->getPosition(),
1512:             $keys[5] => $this->getCreatedAt(),
1513:             $keys[6] => $this->getUpdatedAt(),
1514:             $keys[7] => $this->getVersion(),
1515:             $keys[8] => $this->getVersionCreatedAt(),
1516:             $keys[9] => $this->getVersionCreatedBy(),
1517:         );
1518:         if ($includeForeignObjects) {
1519:             if (null !== $this->collProductCategorys) {
1520:                 $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1521:             }
1522:             if (null !== $this->collFeatureCategorys) {
1523:                 $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1524:             }
1525:             if (null !== $this->collAttributeCategorys) {
1526:                 $result['AttributeCategorys'] = $this->collAttributeCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1527:             }
1528:             if (null !== $this->collContentAssocs) {
1529:                 $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1530:             }
1531:             if (null !== $this->collImages) {
1532:                 $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1533:             }
1534:             if (null !== $this->collDocuments) {
1535:                 $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1536:             }
1537:             if (null !== $this->collRewritings) {
1538:                 $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1539:             }
1540:             if (null !== $this->collCategoryI18ns) {
1541:                 $result['CategoryI18ns'] = $this->collCategoryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1542:             }
1543:             if (null !== $this->collCategoryVersions) {
1544:                 $result['CategoryVersions'] = $this->collCategoryVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1545:             }
1546:         }
1547: 
1548:         return $result;
1549:     }
1550: 
1551:     /**
1552:      * Sets a field from the object by name passed in as a string.
1553:      *
1554:      * @param string $name peer name
1555:      * @param mixed $value field value
1556:      * @param string $type The type of fieldname the $name is of:
1557:      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
1558:      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1559:      *                     Defaults to BasePeer::TYPE_PHPNAME
1560:      * @return void
1561:      */
1562:     public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
1563:     {
1564:         $pos = CategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1565: 
1566:         $this->setByPosition($pos, $value);
1567:     }
1568: 
1569:     /**
1570:      * Sets a field from the object by Position as specified in the xml schema.
1571:      * Zero-based.
1572:      *
1573:      * @param int $pos position in xml schema
1574:      * @param mixed $value field value
1575:      * @return void
1576:      */
1577:     public function setByPosition($pos, $value)
1578:     {
1579:         switch ($pos) {
1580:             case 0:
1581:                 $this->setId($value);
1582:                 break;
1583:             case 1:
1584:                 $this->setParent($value);
1585:                 break;
1586:             case 2:
1587:                 $this->setLink($value);
1588:                 break;
1589:             case 3:
1590:                 $this->setVisible($value);
1591:                 break;
1592:             case 4:
1593:                 $this->setPosition($value);
1594:                 break;
1595:             case 5:
1596:                 $this->setCreatedAt($value);
1597:                 break;
1598:             case 6:
1599:                 $this->setUpdatedAt($value);
1600:                 break;
1601:             case 7:
1602:                 $this->setVersion($value);
1603:                 break;
1604:             case 8:
1605:                 $this->setVersionCreatedAt($value);
1606:                 break;
1607:             case 9:
1608:                 $this->setVersionCreatedBy($value);
1609:                 break;
1610:         } // switch()
1611:     }
1612: 
1613:     /**
1614:      * Populates the object using an array.
1615:      *
1616:      * This is particularly useful when populating an object from one of the
1617:      * request arrays (e.g. $_POST).  This method goes through the column
1618:      * names, checking to see whether a matching key exists in populated
1619:      * array. If so the setByName() method is called for that column.
1620:      *
1621:      * You can specify the key type of the array by additionally passing one
1622:      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1623:      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1624:      * The default key type is the column's BasePeer::TYPE_PHPNAME
1625:      *
1626:      * @param array  $arr     An array to populate the object from.
1627:      * @param string $keyType The type of keys the array uses.
1628:      * @return void
1629:      */
1630:     public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
1631:     {
1632:         $keys = CategoryPeer::getFieldNames($keyType);
1633: 
1634:         if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
1635:         if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]);
1636:         if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]);
1637:         if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]);
1638:         if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
1639:         if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
1640:         if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
1641:         if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]);
1642:         if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]);
1643:         if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]);
1644:     }
1645: 
1646:     /**
1647:      * Build a Criteria object containing the values of all modified columns in this object.
1648:      *
1649:      * @return Criteria The Criteria object containing all modified values.
1650:      */
1651:     public function buildCriteria()
1652:     {
1653:         $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
1654: 
1655:         if ($this->isColumnModified(CategoryPeer::ID)) $criteria->add(CategoryPeer::ID, $this->id);
1656:         if ($this->isColumnModified(CategoryPeer::PARENT)) $criteria->add(CategoryPeer::PARENT, $this->parent);
1657:         if ($this->isColumnModified(CategoryPeer::LINK)) $criteria->add(CategoryPeer::LINK, $this->link);
1658:         if ($this->isColumnModified(CategoryPeer::VISIBLE)) $criteria->add(CategoryPeer::VISIBLE, $this->visible);
1659:         if ($this->isColumnModified(CategoryPeer::POSITION)) $criteria->add(CategoryPeer::POSITION, $this->position);
1660:         if ($this->isColumnModified(CategoryPeer::CREATED_AT)) $criteria->add(CategoryPeer::CREATED_AT, $this->created_at);
1661:         if ($this->isColumnModified(CategoryPeer::UPDATED_AT)) $criteria->add(CategoryPeer::UPDATED_AT, $this->updated_at);
1662:         if ($this->isColumnModified(CategoryPeer::VERSION)) $criteria->add(CategoryPeer::VERSION, $this->version);
1663:         if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_AT)) $criteria->add(CategoryPeer::VERSION_CREATED_AT, $this->version_created_at);
1664:         if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_BY)) $criteria->add(CategoryPeer::VERSION_CREATED_BY, $this->version_created_by);
1665: 
1666:         return $criteria;
1667:     }
1668: 
1669:     /**
1670:      * Builds a Criteria object containing the primary key for this object.
1671:      *
1672:      * Unlike buildCriteria() this method includes the primary key values regardless
1673:      * of whether or not they have been modified.
1674:      *
1675:      * @return Criteria The Criteria object containing value(s) for primary key(s).
1676:      */
1677:     public function buildPkeyCriteria()
1678:     {
1679:         $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
1680:         $criteria->add(CategoryPeer::ID, $this->id);
1681: 
1682:         return $criteria;
1683:     }
1684: 
1685:     /**
1686:      * Returns the primary key for this object (row).
1687:      * @return int
1688:      */
1689:     public function getPrimaryKey()
1690:     {
1691:         return $this->getId();
1692:     }
1693: 
1694:     /**
1695:      * Generic method to set the primary key (id column).
1696:      *
1697:      * @param  int $key Primary key.
1698:      * @return void
1699:      */
1700:     public function setPrimaryKey($key)
1701:     {
1702:         $this->setId($key);
1703:     }
1704: 
1705:     /**
1706:      * Returns true if the primary key for this object is null.
1707:      * @return boolean
1708:      */
1709:     public function isPrimaryKeyNull()
1710:     {
1711: 
1712:         return null === $this->getId();
1713:     }
1714: 
1715:     /**
1716:      * Sets contents of passed object to values from current object.
1717:      *
1718:      * If desired, this method can also make copies of all associated (fkey referrers)
1719:      * objects.
1720:      *
1721:      * @param object $copyObj An object of Category (or compatible) type.
1722:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1723:      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1724:      * @throws PropelException
1725:      */
1726:     public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1727:     {
1728:         $copyObj->setParent($this->getParent());
1729:         $copyObj->setLink($this->getLink());
1730:         $copyObj->setVisible($this->getVisible());
1731:         $copyObj->setPosition($this->getPosition());
1732:         $copyObj->setCreatedAt($this->getCreatedAt());
1733:         $copyObj->setUpdatedAt($this->getUpdatedAt());
1734:         $copyObj->setVersion($this->getVersion());
1735:         $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
1736:         $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
1737: 
1738:         if ($deepCopy && !$this->startCopy) {
1739:             // important: temporarily setNew(false) because this affects the behavior of
1740:             // the getter/setter methods for fkey referrer objects.
1741:             $copyObj->setNew(false);
1742:             // store object hash to prevent cycle
1743:             $this->startCopy = true;
1744: 
1745:             foreach ($this->getProductCategorys() as $relObj) {
1746:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1747:                     $copyObj->addProductCategory($relObj->copy($deepCopy));
1748:                 }
1749:             }
1750: 
1751:             foreach ($this->getFeatureCategorys() as $relObj) {
1752:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1753:                     $copyObj->addFeatureCategory($relObj->copy($deepCopy));
1754:                 }
1755:             }
1756: 
1757:             foreach ($this->getAttributeCategorys() as $relObj) {
1758:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1759:                     $copyObj->addAttributeCategory($relObj->copy($deepCopy));
1760:                 }
1761:             }
1762: 
1763:             foreach ($this->getContentAssocs() as $relObj) {
1764:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1765:                     $copyObj->addContentAssoc($relObj->copy($deepCopy));
1766:                 }
1767:             }
1768: 
1769:             foreach ($this->getImages() as $relObj) {
1770:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1771:                     $copyObj->addImage($relObj->copy($deepCopy));
1772:                 }
1773:             }
1774: 
1775:             foreach ($this->getDocuments() as $relObj) {
1776:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1777:                     $copyObj->addDocument($relObj->copy($deepCopy));
1778:                 }
1779:             }
1780: 
1781:             foreach ($this->getRewritings() as $relObj) {
1782:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1783:                     $copyObj->addRewriting($relObj->copy($deepCopy));
1784:                 }
1785:             }
1786: 
1787:             foreach ($this->getCategoryI18ns() as $relObj) {
1788:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1789:                     $copyObj->addCategoryI18n($relObj->copy($deepCopy));
1790:                 }
1791:             }
1792: 
1793:             foreach ($this->getCategoryVersions() as $relObj) {
1794:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1795:                     $copyObj->addCategoryVersion($relObj->copy($deepCopy));
1796:                 }
1797:             }
1798: 
1799:             //unflag object copy
1800:             $this->startCopy = false;
1801:         } // if ($deepCopy)
1802: 
1803:         if ($makeNew) {
1804:             $copyObj->setNew(true);
1805:             $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
1806:         }
1807:     }
1808: 
1809:     /**
1810:      * Makes a copy of this object that will be inserted as a new row in table when saved.
1811:      * It creates a new object filling in the simple attributes, but skipping any primary
1812:      * keys that are defined for the table.
1813:      *
1814:      * If desired, this method can also make copies of all associated (fkey referrers)
1815:      * objects.
1816:      *
1817:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1818:      * @return Category Clone of current object.
1819:      * @throws PropelException
1820:      */
1821:     public function copy($deepCopy = false)
1822:     {
1823:         // we use get_class(), because this might be a subclass
1824:         $clazz = get_class($this);
1825:         $copyObj = new $clazz();
1826:         $this->copyInto($copyObj, $deepCopy);
1827: 
1828:         return $copyObj;
1829:     }
1830: 
1831:     /**
1832:      * Returns a peer instance associated with this om.
1833:      *
1834:      * Since Peer classes are not to have any instance attributes, this method returns the
1835:      * same instance for all member of this class. The method could therefore
1836:      * be static, but this would prevent one from overriding the behavior.
1837:      *
1838:      * @return CategoryPeer
1839:      */
1840:     public function getPeer()
1841:     {
1842:         if (self::$peer === null) {
1843:             self::$peer = new CategoryPeer();
1844:         }
1845: 
1846:         return self::$peer;
1847:     }
1848: 
1849: 
1850:     /**
1851:      * Initializes a collection based on the name of a relation.
1852:      * Avoids crafting an 'init[$relationName]s' method name
1853:      * that wouldn't work when StandardEnglishPluralizer is used.
1854:      *
1855:      * @param string $relationName The name of the relation to initialize
1856:      * @return void
1857:      */
1858:     public function initRelation($relationName)
1859:     {
1860:         if ('ProductCategory' == $relationName) {
1861:             $this->initProductCategorys();
1862:         }
1863:         if ('FeatureCategory' == $relationName) {
1864:             $this->initFeatureCategorys();
1865:         }
1866:         if ('AttributeCategory' == $relationName) {
1867:             $this->initAttributeCategorys();
1868:         }
1869:         if ('ContentAssoc' == $relationName) {
1870:             $this->initContentAssocs();
1871:         }
1872:         if ('Image' == $relationName) {
1873:             $this->initImages();
1874:         }
1875:         if ('Document' == $relationName) {
1876:             $this->initDocuments();
1877:         }
1878:         if ('Rewriting' == $relationName) {
1879:             $this->initRewritings();
1880:         }
1881:         if ('CategoryI18n' == $relationName) {
1882:             $this->initCategoryI18ns();
1883:         }
1884:         if ('CategoryVersion' == $relationName) {
1885:             $this->initCategoryVersions();
1886:         }
1887:     }
1888: 
1889:     /**
1890:      * Clears out the collProductCategorys collection
1891:      *
1892:      * This does not modify the database; however, it will remove any associated objects, causing
1893:      * them to be refetched by subsequent calls to accessor method.
1894:      *
1895:      * @return Category The current object (for fluent API support)
1896:      * @see        addProductCategorys()
1897:      */
1898:     public function clearProductCategorys()
1899:     {
1900:         $this->collProductCategorys = null; // important to set this to null since that means it is uninitialized
1901:         $this->collProductCategorysPartial = null;
1902: 
1903:         return $this;
1904:     }
1905: 
1906:     /**
1907:      * reset is the collProductCategorys collection loaded partially
1908:      *
1909:      * @return void
1910:      */
1911:     public function resetPartialProductCategorys($v = true)
1912:     {
1913:         $this->collProductCategorysPartial = $v;
1914:     }
1915: 
1916:     /**
1917:      * Initializes the collProductCategorys collection.
1918:      *
1919:      * By default this just sets the collProductCategorys collection to an empty array (like clearcollProductCategorys());
1920:      * however, you may wish to override this method in your stub class to provide setting appropriate
1921:      * to your application -- for example, setting the initial array to the values stored in database.
1922:      *
1923:      * @param boolean $overrideExisting If set to true, the method call initializes
1924:      *                                        the collection even if it is not empty
1925:      *
1926:      * @return void
1927:      */
1928:     public function initProductCategorys($overrideExisting = true)
1929:     {
1930:         if (null !== $this->collProductCategorys && !$overrideExisting) {
1931:             return;
1932:         }
1933:         $this->collProductCategorys = new PropelObjectCollection();
1934:         $this->collProductCategorys->setModel('ProductCategory');
1935:     }
1936: 
1937:     /**
1938:      * Gets an array of ProductCategory objects which contain a foreign key that references this object.
1939:      *
1940:      * If the $criteria is not null, it is used to always fetch the results from the database.
1941:      * Otherwise the results are fetched from the database the first time, then cached.
1942:      * Next time the same method is called without $criteria, the cached collection is returned.
1943:      * If this Category is new, it will return
1944:      * an empty collection or the current collection; the criteria is ignored on a new object.
1945:      *
1946:      * @param Criteria $criteria optional Criteria object to narrow the query
1947:      * @param PropelPDO $con optional connection object
1948:      * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects
1949:      * @throws PropelException
1950:      */
1951:     public function getProductCategorys($criteria = null, PropelPDO $con = null)
1952:     {
1953:         $partial = $this->collProductCategorysPartial && !$this->isNew();
1954:         if (null === $this->collProductCategorys || null !== $criteria  || $partial) {
1955:             if ($this->isNew() && null === $this->collProductCategorys) {
1956:                 // return empty collection
1957:                 $this->initProductCategorys();
1958:             } else {
1959:                 $collProductCategorys = ProductCategoryQuery::create(null, $criteria)
1960:                     ->filterByCategory($this)
1961:                     ->find($con);
1962:                 if (null !== $criteria) {
1963:                     if (false !== $this->collProductCategorysPartial && count($collProductCategorys)) {
1964:                       $this->initProductCategorys(false);
1965: 
1966:                       foreach($collProductCategorys as $obj) {
1967:                         if (false == $this->collProductCategorys->contains($obj)) {
1968:                           $this->collProductCategorys->append($obj);
1969:                         }
1970:                       }
1971: 
1972:                       $this->collProductCategorysPartial = true;
1973:                     }
1974: 
1975:                     $collProductCategorys->getInternalIterator()->rewind();
1976:                     return $collProductCategorys;
1977:                 }
1978: 
1979:                 if($partial && $this->collProductCategorys) {
1980:                     foreach($this->collProductCategorys as $obj) {
1981:                         if($obj->isNew()) {
1982:                             $collProductCategorys[] = $obj;
1983:                         }
1984:                     }
1985:                 }
1986: 
1987:                 $this->collProductCategorys = $collProductCategorys;
1988:                 $this->collProductCategorysPartial = false;
1989:             }
1990:         }
1991: 
1992:         return $this->collProductCategorys;
1993:     }
1994: 
1995:     /**
1996:      * Sets a collection of ProductCategory objects related by a one-to-many relationship
1997:      * to the current object.
1998:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1999:      * and new objects from the given Propel collection.
2000:      *
2001:      * @param PropelCollection $productCategorys A Propel collection.
2002:      * @param PropelPDO $con Optional connection object
2003:      * @return Category The current object (for fluent API support)
2004:      */
2005:     public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null)
2006:     {
2007:         $productCategorysToDelete = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys);
2008: 
2009:         $this->productCategorysScheduledForDeletion = unserialize(serialize($productCategorysToDelete));
2010: 
2011:         foreach ($productCategorysToDelete as $productCategoryRemoved) {
2012:             $productCategoryRemoved->setCategory(null);
2013:         }
2014: 
2015:         $this->collProductCategorys = null;
2016:         foreach ($productCategorys as $productCategory) {
2017:             $this->addProductCategory($productCategory);
2018:         }
2019: 
2020:         $this->collProductCategorys = $productCategorys;
2021:         $this->collProductCategorysPartial = false;
2022: 
2023:         return $this;
2024:     }
2025: 
2026:     /**
2027:      * Returns the number of related ProductCategory objects.
2028:      *
2029:      * @param Criteria $criteria
2030:      * @param boolean $distinct
2031:      * @param PropelPDO $con
2032:      * @return int             Count of related ProductCategory objects.
2033:      * @throws PropelException
2034:      */
2035:     public function countProductCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2036:     {
2037:         $partial = $this->collProductCategorysPartial && !$this->isNew();
2038:         if (null === $this->collProductCategorys || null !== $criteria || $partial) {
2039:             if ($this->isNew() && null === $this->collProductCategorys) {
2040:                 return 0;
2041:             }
2042: 
2043:             if($partial && !$criteria) {
2044:                 return count($this->getProductCategorys());
2045:             }
2046:             $query = ProductCategoryQuery::create(null, $criteria);
2047:             if ($distinct) {
2048:                 $query->distinct();
2049:             }
2050: 
2051:             return $query
2052:                 ->filterByCategory($this)
2053:                 ->count($con);
2054:         }
2055: 
2056:         return count($this->collProductCategorys);
2057:     }
2058: 
2059:     /**
2060:      * Method called to associate a ProductCategory object to this object
2061:      * through the ProductCategory foreign key attribute.
2062:      *
2063:      * @param    ProductCategory $l ProductCategory
2064:      * @return Category The current object (for fluent API support)
2065:      */
2066:     public function addProductCategory(ProductCategory $l)
2067:     {
2068:         if ($this->collProductCategorys === null) {
2069:             $this->initProductCategorys();
2070:             $this->collProductCategorysPartial = true;
2071:         }
2072:         if (!in_array($l, $this->collProductCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
2073:             $this->doAddProductCategory($l);
2074:         }
2075: 
2076:         return $this;
2077:     }
2078: 
2079:     /**
2080:      * @param   ProductCategory $productCategory The productCategory object to add.
2081:      */
2082:     protected function doAddProductCategory($productCategory)
2083:     {
2084:         $this->collProductCategorys[]= $productCategory;
2085:         $productCategory->setCategory($this);
2086:     }
2087: 
2088:     /**
2089:      * @param   ProductCategory $productCategory The productCategory object to remove.
2090:      * @return Category The current object (for fluent API support)
2091:      */
2092:     public function removeProductCategory($productCategory)
2093:     {
2094:         if ($this->getProductCategorys()->contains($productCategory)) {
2095:             $this->collProductCategorys->remove($this->collProductCategorys->search($productCategory));
2096:             if (null === $this->productCategorysScheduledForDeletion) {
2097:                 $this->productCategorysScheduledForDeletion = clone $this->collProductCategorys;
2098:                 $this->productCategorysScheduledForDeletion->clear();
2099:             }
2100:             $this->productCategorysScheduledForDeletion[]= clone $productCategory;
2101:             $productCategory->setCategory(null);
2102:         }
2103: 
2104:         return $this;
2105:     }
2106: 
2107: 
2108:     /**
2109:      * If this collection has already been initialized with
2110:      * an identical criteria, it returns the collection.
2111:      * Otherwise if this Category is new, it will return
2112:      * an empty collection; or if this Category has previously
2113:      * been saved, it will retrieve related ProductCategorys from storage.
2114:      *
2115:      * This method is protected by default in order to keep the public
2116:      * api reasonable.  You can provide public methods for those you
2117:      * actually need in Category.
2118:      *
2119:      * @param Criteria $criteria optional Criteria object to narrow the query
2120:      * @param PropelPDO $con optional connection object
2121:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2122:      * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects
2123:      */
2124:     public function getProductCategorysJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2125:     {
2126:         $query = ProductCategoryQuery::create(null, $criteria);
2127:         $query->joinWith('Product', $join_behavior);
2128: 
2129:         return $this->getProductCategorys($query, $con);
2130:     }
2131: 
2132:     /**
2133:      * Clears out the collFeatureCategorys collection
2134:      *
2135:      * This does not modify the database; however, it will remove any associated objects, causing
2136:      * them to be refetched by subsequent calls to accessor method.
2137:      *
2138:      * @return Category The current object (for fluent API support)
2139:      * @see        addFeatureCategorys()
2140:      */
2141:     public function clearFeatureCategorys()
2142:     {
2143:         $this->collFeatureCategorys = null; // important to set this to null since that means it is uninitialized
2144:         $this->collFeatureCategorysPartial = null;
2145: 
2146:         return $this;
2147:     }
2148: 
2149:     /**
2150:      * reset is the collFeatureCategorys collection loaded partially
2151:      *
2152:      * @return void
2153:      */
2154:     public function resetPartialFeatureCategorys($v = true)
2155:     {
2156:         $this->collFeatureCategorysPartial = $v;
2157:     }
2158: 
2159:     /**
2160:      * Initializes the collFeatureCategorys collection.
2161:      *
2162:      * By default this just sets the collFeatureCategorys collection to an empty array (like clearcollFeatureCategorys());
2163:      * however, you may wish to override this method in your stub class to provide setting appropriate
2164:      * to your application -- for example, setting the initial array to the values stored in database.
2165:      *
2166:      * @param boolean $overrideExisting If set to true, the method call initializes
2167:      *                                        the collection even if it is not empty
2168:      *
2169:      * @return void
2170:      */
2171:     public function initFeatureCategorys($overrideExisting = true)
2172:     {
2173:         if (null !== $this->collFeatureCategorys && !$overrideExisting) {
2174:             return;
2175:         }
2176:         $this->collFeatureCategorys = new PropelObjectCollection();
2177:         $this->collFeatureCategorys->setModel('FeatureCategory');
2178:     }
2179: 
2180:     /**
2181:      * Gets an array of FeatureCategory objects which contain a foreign key that references this object.
2182:      *
2183:      * If the $criteria is not null, it is used to always fetch the results from the database.
2184:      * Otherwise the results are fetched from the database the first time, then cached.
2185:      * Next time the same method is called without $criteria, the cached collection is returned.
2186:      * If this Category is new, it will return
2187:      * an empty collection or the current collection; the criteria is ignored on a new object.
2188:      *
2189:      * @param Criteria $criteria optional Criteria object to narrow the query
2190:      * @param PropelPDO $con optional connection object
2191:      * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects
2192:      * @throws PropelException
2193:      */
2194:     public function getFeatureCategorys($criteria = null, PropelPDO $con = null)
2195:     {
2196:         $partial = $this->collFeatureCategorysPartial && !$this->isNew();
2197:         if (null === $this->collFeatureCategorys || null !== $criteria  || $partial) {
2198:             if ($this->isNew() && null === $this->collFeatureCategorys) {
2199:                 // return empty collection
2200:                 $this->initFeatureCategorys();
2201:             } else {
2202:                 $collFeatureCategorys = FeatureCategoryQuery::create(null, $criteria)
2203:                     ->filterByCategory($this)
2204:                     ->find($con);
2205:                 if (null !== $criteria) {
2206:                     if (false !== $this->collFeatureCategorysPartial && count($collFeatureCategorys)) {
2207:                       $this->initFeatureCategorys(false);
2208: 
2209:                       foreach($collFeatureCategorys as $obj) {
2210:                         if (false == $this->collFeatureCategorys->contains($obj)) {
2211:                           $this->collFeatureCategorys->append($obj);
2212:                         }
2213:                       }
2214: 
2215:                       $this->collFeatureCategorysPartial = true;
2216:                     }
2217: 
2218:                     $collFeatureCategorys->getInternalIterator()->rewind();
2219:                     return $collFeatureCategorys;
2220:                 }
2221: 
2222:                 if($partial && $this->collFeatureCategorys) {
2223:                     foreach($this->collFeatureCategorys as $obj) {
2224:                         if($obj->isNew()) {
2225:                             $collFeatureCategorys[] = $obj;
2226:                         }
2227:                     }
2228:                 }
2229: 
2230:                 $this->collFeatureCategorys = $collFeatureCategorys;
2231:                 $this->collFeatureCategorysPartial = false;
2232:             }
2233:         }
2234: 
2235:         return $this->collFeatureCategorys;
2236:     }
2237: 
2238:     /**
2239:      * Sets a collection of FeatureCategory objects related by a one-to-many relationship
2240:      * to the current object.
2241:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2242:      * and new objects from the given Propel collection.
2243:      *
2244:      * @param PropelCollection $featureCategorys A Propel collection.
2245:      * @param PropelPDO $con Optional connection object
2246:      * @return Category The current object (for fluent API support)
2247:      */
2248:     public function setFeatureCategorys(PropelCollection $featureCategorys, PropelPDO $con = null)
2249:     {
2250:         $featureCategorysToDelete = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys);
2251: 
2252:         $this->featureCategorysScheduledForDeletion = unserialize(serialize($featureCategorysToDelete));
2253: 
2254:         foreach ($featureCategorysToDelete as $featureCategoryRemoved) {
2255:             $featureCategoryRemoved->setCategory(null);
2256:         }
2257: 
2258:         $this->collFeatureCategorys = null;
2259:         foreach ($featureCategorys as $featureCategory) {
2260:             $this->addFeatureCategory($featureCategory);
2261:         }
2262: 
2263:         $this->collFeatureCategorys = $featureCategorys;
2264:         $this->collFeatureCategorysPartial = false;
2265: 
2266:         return $this;
2267:     }
2268: 
2269:     /**
2270:      * Returns the number of related FeatureCategory objects.
2271:      *
2272:      * @param Criteria $criteria
2273:      * @param boolean $distinct
2274:      * @param PropelPDO $con
2275:      * @return int             Count of related FeatureCategory objects.
2276:      * @throws PropelException
2277:      */
2278:     public function countFeatureCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2279:     {
2280:         $partial = $this->collFeatureCategorysPartial && !$this->isNew();
2281:         if (null === $this->collFeatureCategorys || null !== $criteria || $partial) {
2282:             if ($this->isNew() && null === $this->collFeatureCategorys) {
2283:                 return 0;
2284:             }
2285: 
2286:             if($partial && !$criteria) {
2287:                 return count($this->getFeatureCategorys());
2288:             }
2289:             $query = FeatureCategoryQuery::create(null, $criteria);
2290:             if ($distinct) {
2291:                 $query->distinct();
2292:             }
2293: 
2294:             return $query
2295:                 ->filterByCategory($this)
2296:                 ->count($con);
2297:         }
2298: 
2299:         return count($this->collFeatureCategorys);
2300:     }
2301: 
2302:     /**
2303:      * Method called to associate a FeatureCategory object to this object
2304:      * through the FeatureCategory foreign key attribute.
2305:      *
2306:      * @param    FeatureCategory $l FeatureCategory
2307:      * @return Category The current object (for fluent API support)
2308:      */
2309:     public function addFeatureCategory(FeatureCategory $l)
2310:     {
2311:         if ($this->collFeatureCategorys === null) {
2312:             $this->initFeatureCategorys();
2313:             $this->collFeatureCategorysPartial = true;
2314:         }
2315:         if (!in_array($l, $this->collFeatureCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
2316:             $this->doAddFeatureCategory($l);
2317:         }
2318: 
2319:         return $this;
2320:     }
2321: 
2322:     /**
2323:      * @param   FeatureCategory $featureCategory The featureCategory object to add.
2324:      */
2325:     protected function doAddFeatureCategory($featureCategory)
2326:     {
2327:         $this->collFeatureCategorys[]= $featureCategory;
2328:         $featureCategory->setCategory($this);
2329:     }
2330: 
2331:     /**
2332:      * @param   FeatureCategory $featureCategory The featureCategory object to remove.
2333:      * @return Category The current object (for fluent API support)
2334:      */
2335:     public function removeFeatureCategory($featureCategory)
2336:     {
2337:         if ($this->getFeatureCategorys()->contains($featureCategory)) {
2338:             $this->collFeatureCategorys->remove($this->collFeatureCategorys->search($featureCategory));
2339:             if (null === $this->featureCategorysScheduledForDeletion) {
2340:                 $this->featureCategorysScheduledForDeletion = clone $this->collFeatureCategorys;
2341:                 $this->featureCategorysScheduledForDeletion->clear();
2342:             }
2343:             $this->featureCategorysScheduledForDeletion[]= clone $featureCategory;
2344:             $featureCategory->setCategory(null);
2345:         }
2346: 
2347:         return $this;
2348:     }
2349: 
2350: 
2351:     /**
2352:      * If this collection has already been initialized with
2353:      * an identical criteria, it returns the collection.
2354:      * Otherwise if this Category is new, it will return
2355:      * an empty collection; or if this Category has previously
2356:      * been saved, it will retrieve related FeatureCategorys from storage.
2357:      *
2358:      * This method is protected by default in order to keep the public
2359:      * api reasonable.  You can provide public methods for those you
2360:      * actually need in Category.
2361:      *
2362:      * @param Criteria $criteria optional Criteria object to narrow the query
2363:      * @param PropelPDO $con optional connection object
2364:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2365:      * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects
2366:      */
2367:     public function getFeatureCategorysJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2368:     {
2369:         $query = FeatureCategoryQuery::create(null, $criteria);
2370:         $query->joinWith('Feature', $join_behavior);
2371: 
2372:         return $this->getFeatureCategorys($query, $con);
2373:     }
2374: 
2375:     /**
2376:      * Clears out the collAttributeCategorys collection
2377:      *
2378:      * This does not modify the database; however, it will remove any associated objects, causing
2379:      * them to be refetched by subsequent calls to accessor method.
2380:      *
2381:      * @return Category The current object (for fluent API support)
2382:      * @see        addAttributeCategorys()
2383:      */
2384:     public function clearAttributeCategorys()
2385:     {
2386:         $this->collAttributeCategorys = null; // important to set this to null since that means it is uninitialized
2387:         $this->collAttributeCategorysPartial = null;
2388: 
2389:         return $this;
2390:     }
2391: 
2392:     /**
2393:      * reset is the collAttributeCategorys collection loaded partially
2394:      *
2395:      * @return void
2396:      */
2397:     public function resetPartialAttributeCategorys($v = true)
2398:     {
2399:         $this->collAttributeCategorysPartial = $v;
2400:     }
2401: 
2402:     /**
2403:      * Initializes the collAttributeCategorys collection.
2404:      *
2405:      * By default this just sets the collAttributeCategorys collection to an empty array (like clearcollAttributeCategorys());
2406:      * however, you may wish to override this method in your stub class to provide setting appropriate
2407:      * to your application -- for example, setting the initial array to the values stored in database.
2408:      *
2409:      * @param boolean $overrideExisting If set to true, the method call initializes
2410:      *                                        the collection even if it is not empty
2411:      *
2412:      * @return void
2413:      */
2414:     public function initAttributeCategorys($overrideExisting = true)
2415:     {
2416:         if (null !== $this->collAttributeCategorys && !$overrideExisting) {
2417:             return;
2418:         }
2419:         $this->collAttributeCategorys = new PropelObjectCollection();
2420:         $this->collAttributeCategorys->setModel('AttributeCategory');
2421:     }
2422: 
2423:     /**
2424:      * Gets an array of AttributeCategory objects which contain a foreign key that references this object.
2425:      *
2426:      * If the $criteria is not null, it is used to always fetch the results from the database.
2427:      * Otherwise the results are fetched from the database the first time, then cached.
2428:      * Next time the same method is called without $criteria, the cached collection is returned.
2429:      * If this Category is new, it will return
2430:      * an empty collection or the current collection; the criteria is ignored on a new object.
2431:      *
2432:      * @param Criteria $criteria optional Criteria object to narrow the query
2433:      * @param PropelPDO $con optional connection object
2434:      * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects
2435:      * @throws PropelException
2436:      */
2437:     public function getAttributeCategorys($criteria = null, PropelPDO $con = null)
2438:     {
2439:         $partial = $this->collAttributeCategorysPartial && !$this->isNew();
2440:         if (null === $this->collAttributeCategorys || null !== $criteria  || $partial) {
2441:             if ($this->isNew() && null === $this->collAttributeCategorys) {
2442:                 // return empty collection
2443:                 $this->initAttributeCategorys();
2444:             } else {
2445:                 $collAttributeCategorys = AttributeCategoryQuery::create(null, $criteria)
2446:                     ->filterByCategory($this)
2447:                     ->find($con);
2448:                 if (null !== $criteria) {
2449:                     if (false !== $this->collAttributeCategorysPartial && count($collAttributeCategorys)) {
2450:                       $this->initAttributeCategorys(false);
2451: 
2452:                       foreach($collAttributeCategorys as $obj) {
2453:                         if (false == $this->collAttributeCategorys->contains($obj)) {
2454:                           $this->collAttributeCategorys->append($obj);
2455:                         }
2456:                       }
2457: 
2458:                       $this->collAttributeCategorysPartial = true;
2459:                     }
2460: 
2461:                     $collAttributeCategorys->getInternalIterator()->rewind();
2462:                     return $collAttributeCategorys;
2463:                 }
2464: 
2465:                 if($partial && $this->collAttributeCategorys) {
2466:                     foreach($this->collAttributeCategorys as $obj) {
2467:                         if($obj->isNew()) {
2468:                             $collAttributeCategorys[] = $obj;
2469:                         }
2470:                     }
2471:                 }
2472: 
2473:                 $this->collAttributeCategorys = $collAttributeCategorys;
2474:                 $this->collAttributeCategorysPartial = false;
2475:             }
2476:         }
2477: 
2478:         return $this->collAttributeCategorys;
2479:     }
2480: 
2481:     /**
2482:      * Sets a collection of AttributeCategory objects related by a one-to-many relationship
2483:      * to the current object.
2484:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2485:      * and new objects from the given Propel collection.
2486:      *
2487:      * @param PropelCollection $attributeCategorys A Propel collection.
2488:      * @param PropelPDO $con Optional connection object
2489:      * @return Category The current object (for fluent API support)
2490:      */
2491:     public function setAttributeCategorys(PropelCollection $attributeCategorys, PropelPDO $con = null)
2492:     {
2493:         $attributeCategorysToDelete = $this->getAttributeCategorys(new Criteria(), $con)->diff($attributeCategorys);
2494: 
2495:         $this->attributeCategorysScheduledForDeletion = unserialize(serialize($attributeCategorysToDelete));
2496: 
2497:         foreach ($attributeCategorysToDelete as $attributeCategoryRemoved) {
2498:             $attributeCategoryRemoved->setCategory(null);
2499:         }
2500: 
2501:         $this->collAttributeCategorys = null;
2502:         foreach ($attributeCategorys as $attributeCategory) {
2503:             $this->addAttributeCategory($attributeCategory);
2504:         }
2505: 
2506:         $this->collAttributeCategorys = $attributeCategorys;
2507:         $this->collAttributeCategorysPartial = false;
2508: 
2509:         return $this;
2510:     }
2511: 
2512:     /**
2513:      * Returns the number of related AttributeCategory objects.
2514:      *
2515:      * @param Criteria $criteria
2516:      * @param boolean $distinct
2517:      * @param PropelPDO $con
2518:      * @return int             Count of related AttributeCategory objects.
2519:      * @throws PropelException
2520:      */
2521:     public function countAttributeCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2522:     {
2523:         $partial = $this->collAttributeCategorysPartial && !$this->isNew();
2524:         if (null === $this->collAttributeCategorys || null !== $criteria || $partial) {
2525:             if ($this->isNew() && null === $this->collAttributeCategorys) {
2526:                 return 0;
2527:             }
2528: 
2529:             if($partial && !$criteria) {
2530:                 return count($this->getAttributeCategorys());
2531:             }
2532:             $query = AttributeCategoryQuery::create(null, $criteria);
2533:             if ($distinct) {
2534:                 $query->distinct();
2535:             }
2536: 
2537:             return $query
2538:                 ->filterByCategory($this)
2539:                 ->count($con);
2540:         }
2541: 
2542:         return count($this->collAttributeCategorys);
2543:     }
2544: 
2545:     /**
2546:      * Method called to associate a AttributeCategory object to this object
2547:      * through the AttributeCategory foreign key attribute.
2548:      *
2549:      * @param    AttributeCategory $l AttributeCategory
2550:      * @return Category The current object (for fluent API support)
2551:      */
2552:     public function addAttributeCategory(AttributeCategory $l)
2553:     {
2554:         if ($this->collAttributeCategorys === null) {
2555:             $this->initAttributeCategorys();
2556:             $this->collAttributeCategorysPartial = true;
2557:         }
2558:         if (!in_array($l, $this->collAttributeCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
2559:             $this->doAddAttributeCategory($l);
2560:         }
2561: 
2562:         return $this;
2563:     }
2564: 
2565:     /**
2566:      * @param   AttributeCategory $attributeCategory The attributeCategory object to add.
2567:      */
2568:     protected function doAddAttributeCategory($attributeCategory)
2569:     {
2570:         $this->collAttributeCategorys[]= $attributeCategory;
2571:         $attributeCategory->setCategory($this);
2572:     }
2573: 
2574:     /**
2575:      * @param   AttributeCategory $attributeCategory The attributeCategory object to remove.
2576:      * @return Category The current object (for fluent API support)
2577:      */
2578:     public function removeAttributeCategory($attributeCategory)
2579:     {
2580:         if ($this->getAttributeCategorys()->contains($attributeCategory)) {
2581:             $this->collAttributeCategorys->remove($this->collAttributeCategorys->search($attributeCategory));
2582:             if (null === $this->attributeCategorysScheduledForDeletion) {
2583:                 $this->attributeCategorysScheduledForDeletion = clone $this->collAttributeCategorys;
2584:                 $this->attributeCategorysScheduledForDeletion->clear();
2585:             }
2586:             $this->attributeCategorysScheduledForDeletion[]= clone $attributeCategory;
2587:             $attributeCategory->setCategory(null);
2588:         }
2589: 
2590:         return $this;
2591:     }
2592: 
2593: 
2594:     /**
2595:      * If this collection has already been initialized with
2596:      * an identical criteria, it returns the collection.
2597:      * Otherwise if this Category is new, it will return
2598:      * an empty collection; or if this Category has previously
2599:      * been saved, it will retrieve related AttributeCategorys from storage.
2600:      *
2601:      * This method is protected by default in order to keep the public
2602:      * api reasonable.  You can provide public methods for those you
2603:      * actually need in Category.
2604:      *
2605:      * @param Criteria $criteria optional Criteria object to narrow the query
2606:      * @param PropelPDO $con optional connection object
2607:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2608:      * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects
2609:      */
2610:     public function getAttributeCategorysJoinAttribute($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2611:     {
2612:         $query = AttributeCategoryQuery::create(null, $criteria);
2613:         $query->joinWith('Attribute', $join_behavior);
2614: 
2615:         return $this->getAttributeCategorys($query, $con);
2616:     }
2617: 
2618:     /**
2619:      * Clears out the collContentAssocs collection
2620:      *
2621:      * This does not modify the database; however, it will remove any associated objects, causing
2622:      * them to be refetched by subsequent calls to accessor method.
2623:      *
2624:      * @return Category The current object (for fluent API support)
2625:      * @see        addContentAssocs()
2626:      */
2627:     public function clearContentAssocs()
2628:     {
2629:         $this->collContentAssocs = null; // important to set this to null since that means it is uninitialized
2630:         $this->collContentAssocsPartial = null;
2631: 
2632:         return $this;
2633:     }
2634: 
2635:     /**
2636:      * reset is the collContentAssocs collection loaded partially
2637:      *
2638:      * @return void
2639:      */
2640:     public function resetPartialContentAssocs($v = true)
2641:     {
2642:         $this->collContentAssocsPartial = $v;
2643:     }
2644: 
2645:     /**
2646:      * Initializes the collContentAssocs collection.
2647:      *
2648:      * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs());
2649:      * however, you may wish to override this method in your stub class to provide setting appropriate
2650:      * to your application -- for example, setting the initial array to the values stored in database.
2651:      *
2652:      * @param boolean $overrideExisting If set to true, the method call initializes
2653:      *                                        the collection even if it is not empty
2654:      *
2655:      * @return void
2656:      */
2657:     public function initContentAssocs($overrideExisting = true)
2658:     {
2659:         if (null !== $this->collContentAssocs && !$overrideExisting) {
2660:             return;
2661:         }
2662:         $this->collContentAssocs = new PropelObjectCollection();
2663:         $this->collContentAssocs->setModel('ContentAssoc');
2664:     }
2665: 
2666:     /**
2667:      * Gets an array of ContentAssoc objects which contain a foreign key that references this object.
2668:      *
2669:      * If the $criteria is not null, it is used to always fetch the results from the database.
2670:      * Otherwise the results are fetched from the database the first time, then cached.
2671:      * Next time the same method is called without $criteria, the cached collection is returned.
2672:      * If this Category is new, it will return
2673:      * an empty collection or the current collection; the criteria is ignored on a new object.
2674:      *
2675:      * @param Criteria $criteria optional Criteria object to narrow the query
2676:      * @param PropelPDO $con optional connection object
2677:      * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects
2678:      * @throws PropelException
2679:      */
2680:     public function getContentAssocs($criteria = null, PropelPDO $con = null)
2681:     {
2682:         $partial = $this->collContentAssocsPartial && !$this->isNew();
2683:         if (null === $this->collContentAssocs || null !== $criteria  || $partial) {
2684:             if ($this->isNew() && null === $this->collContentAssocs) {
2685:                 // return empty collection
2686:                 $this->initContentAssocs();
2687:             } else {
2688:                 $collContentAssocs = ContentAssocQuery::create(null, $criteria)
2689:                     ->filterByCategory($this)
2690:                     ->find($con);
2691:                 if (null !== $criteria) {
2692:                     if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) {
2693:                       $this->initContentAssocs(false);
2694: 
2695:                       foreach($collContentAssocs as $obj) {
2696:                         if (false == $this->collContentAssocs->contains($obj)) {
2697:                           $this->collContentAssocs->append($obj);
2698:                         }
2699:                       }
2700: 
2701:                       $this->collContentAssocsPartial = true;
2702:                     }
2703: 
2704:                     $collContentAssocs->getInternalIterator()->rewind();
2705:                     return $collContentAssocs;
2706:                 }
2707: 
2708:                 if($partial && $this->collContentAssocs) {
2709:                     foreach($this->collContentAssocs as $obj) {
2710:                         if($obj->isNew()) {
2711:                             $collContentAssocs[] = $obj;
2712:                         }
2713:                     }
2714:                 }
2715: 
2716:                 $this->collContentAssocs = $collContentAssocs;
2717:                 $this->collContentAssocsPartial = false;
2718:             }
2719:         }
2720: 
2721:         return $this->collContentAssocs;
2722:     }
2723: 
2724:     /**
2725:      * Sets a collection of ContentAssoc objects related by a one-to-many relationship
2726:      * to the current object.
2727:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2728:      * and new objects from the given Propel collection.
2729:      *
2730:      * @param PropelCollection $contentAssocs A Propel collection.
2731:      * @param PropelPDO $con Optional connection object
2732:      * @return Category The current object (for fluent API support)
2733:      */
2734:     public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null)
2735:     {
2736:         $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs);
2737: 
2738:         $this->contentAssocsScheduledForDeletion = unserialize(serialize($contentAssocsToDelete));
2739: 
2740:         foreach ($contentAssocsToDelete as $contentAssocRemoved) {
2741:             $contentAssocRemoved->setCategory(null);
2742:         }
2743: 
2744:         $this->collContentAssocs = null;
2745:         foreach ($contentAssocs as $contentAssoc) {
2746:             $this->addContentAssoc($contentAssoc);
2747:         }
2748: 
2749:         $this->collContentAssocs = $contentAssocs;
2750:         $this->collContentAssocsPartial = false;
2751: 
2752:         return $this;
2753:     }
2754: 
2755:     /**
2756:      * Returns the number of related ContentAssoc objects.
2757:      *
2758:      * @param Criteria $criteria
2759:      * @param boolean $distinct
2760:      * @param PropelPDO $con
2761:      * @return int             Count of related ContentAssoc objects.
2762:      * @throws PropelException
2763:      */
2764:     public function countContentAssocs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2765:     {
2766:         $partial = $this->collContentAssocsPartial && !$this->isNew();
2767:         if (null === $this->collContentAssocs || null !== $criteria || $partial) {
2768:             if ($this->isNew() && null === $this->collContentAssocs) {
2769:                 return 0;
2770:             }
2771: 
2772:             if($partial && !$criteria) {
2773:                 return count($this->getContentAssocs());
2774:             }
2775:             $query = ContentAssocQuery::create(null, $criteria);
2776:             if ($distinct) {
2777:                 $query->distinct();
2778:             }
2779: 
2780:             return $query
2781:                 ->filterByCategory($this)
2782:                 ->count($con);
2783:         }
2784: 
2785:         return count($this->collContentAssocs);
2786:     }
2787: 
2788:     /**
2789:      * Method called to associate a ContentAssoc object to this object
2790:      * through the ContentAssoc foreign key attribute.
2791:      *
2792:      * @param    ContentAssoc $l ContentAssoc
2793:      * @return Category The current object (for fluent API support)
2794:      */
2795:     public function addContentAssoc(ContentAssoc $l)
2796:     {
2797:         if ($this->collContentAssocs === null) {
2798:             $this->initContentAssocs();
2799:             $this->collContentAssocsPartial = true;
2800:         }
2801:         if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
2802:             $this->doAddContentAssoc($l);
2803:         }
2804: 
2805:         return $this;
2806:     }
2807: 
2808:     /**
2809:      * @param   ContentAssoc $contentAssoc The contentAssoc object to add.
2810:      */
2811:     protected function doAddContentAssoc($contentAssoc)
2812:     {
2813:         $this->collContentAssocs[]= $contentAssoc;
2814:         $contentAssoc->setCategory($this);
2815:     }
2816: 
2817:     /**
2818:      * @param   ContentAssoc $contentAssoc The contentAssoc object to remove.
2819:      * @return Category The current object (for fluent API support)
2820:      */
2821:     public function removeContentAssoc($contentAssoc)
2822:     {
2823:         if ($this->getContentAssocs()->contains($contentAssoc)) {
2824:             $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc));
2825:             if (null === $this->contentAssocsScheduledForDeletion) {
2826:                 $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs;
2827:                 $this->contentAssocsScheduledForDeletion->clear();
2828:             }
2829:             $this->contentAssocsScheduledForDeletion[]= $contentAssoc;
2830:             $contentAssoc->setCategory(null);
2831:         }
2832: 
2833:         return $this;
2834:     }
2835: 
2836: 
2837:     /**
2838:      * If this collection has already been initialized with
2839:      * an identical criteria, it returns the collection.
2840:      * Otherwise if this Category is new, it will return
2841:      * an empty collection; or if this Category has previously
2842:      * been saved, it will retrieve related ContentAssocs from storage.
2843:      *
2844:      * This method is protected by default in order to keep the public
2845:      * api reasonable.  You can provide public methods for those you
2846:      * actually need in Category.
2847:      *
2848:      * @param Criteria $criteria optional Criteria object to narrow the query
2849:      * @param PropelPDO $con optional connection object
2850:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2851:      * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects
2852:      */
2853:     public function getContentAssocsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2854:     {
2855:         $query = ContentAssocQuery::create(null, $criteria);
2856:         $query->joinWith('Product', $join_behavior);
2857: 
2858:         return $this->getContentAssocs($query, $con);
2859:     }
2860: 
2861: 
2862:     /**
2863:      * If this collection has already been initialized with
2864:      * an identical criteria, it returns the collection.
2865:      * Otherwise if this Category is new, it will return
2866:      * an empty collection; or if this Category has previously
2867:      * been saved, it will retrieve related ContentAssocs from storage.
2868:      *
2869:      * This method is protected by default in order to keep the public
2870:      * api reasonable.  You can provide public methods for those you
2871:      * actually need in Category.
2872:      *
2873:      * @param Criteria $criteria optional Criteria object to narrow the query
2874:      * @param PropelPDO $con optional connection object
2875:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2876:      * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects
2877:      */
2878:     public function getContentAssocsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2879:     {
2880:         $query = ContentAssocQuery::create(null, $criteria);
2881:         $query->joinWith('Content', $join_behavior);
2882: 
2883:         return $this->getContentAssocs($query, $con);
2884:     }
2885: 
2886:     /**
2887:      * Clears out the collImages collection
2888:      *
2889:      * This does not modify the database; however, it will remove any associated objects, causing
2890:      * them to be refetched by subsequent calls to accessor method.
2891:      *
2892:      * @return Category The current object (for fluent API support)
2893:      * @see        addImages()
2894:      */
2895:     public function clearImages()
2896:     {
2897:         $this->collImages = null; // important to set this to null since that means it is uninitialized
2898:         $this->collImagesPartial = null;
2899: 
2900:         return $this;
2901:     }
2902: 
2903:     /**
2904:      * reset is the collImages collection loaded partially
2905:      *
2906:      * @return void
2907:      */
2908:     public function resetPartialImages($v = true)
2909:     {
2910:         $this->collImagesPartial = $v;
2911:     }
2912: 
2913:     /**
2914:      * Initializes the collImages collection.
2915:      *
2916:      * By default this just sets the collImages collection to an empty array (like clearcollImages());
2917:      * however, you may wish to override this method in your stub class to provide setting appropriate
2918:      * to your application -- for example, setting the initial array to the values stored in database.
2919:      *
2920:      * @param boolean $overrideExisting If set to true, the method call initializes
2921:      *                                        the collection even if it is not empty
2922:      *
2923:      * @return void
2924:      */
2925:     public function initImages($overrideExisting = true)
2926:     {
2927:         if (null !== $this->collImages && !$overrideExisting) {
2928:             return;
2929:         }
2930:         $this->collImages = new PropelObjectCollection();
2931:         $this->collImages->setModel('Image');
2932:     }
2933: 
2934:     /**
2935:      * Gets an array of Image objects which contain a foreign key that references this object.
2936:      *
2937:      * If the $criteria is not null, it is used to always fetch the results from the database.
2938:      * Otherwise the results are fetched from the database the first time, then cached.
2939:      * Next time the same method is called without $criteria, the cached collection is returned.
2940:      * If this Category is new, it will return
2941:      * an empty collection or the current collection; the criteria is ignored on a new object.
2942:      *
2943:      * @param Criteria $criteria optional Criteria object to narrow the query
2944:      * @param PropelPDO $con optional connection object
2945:      * @return PropelObjectCollection|Image[] List of Image objects
2946:      * @throws PropelException
2947:      */
2948:     public function getImages($criteria = null, PropelPDO $con = null)
2949:     {
2950:         $partial = $this->collImagesPartial && !$this->isNew();
2951:         if (null === $this->collImages || null !== $criteria  || $partial) {
2952:             if ($this->isNew() && null === $this->collImages) {
2953:                 // return empty collection
2954:                 $this->initImages();
2955:             } else {
2956:                 $collImages = ImageQuery::create(null, $criteria)
2957:                     ->filterByCategory($this)
2958:                     ->find($con);
2959:                 if (null !== $criteria) {
2960:                     if (false !== $this->collImagesPartial && count($collImages)) {
2961:                       $this->initImages(false);
2962: 
2963:                       foreach($collImages as $obj) {
2964:                         if (false == $this->collImages->contains($obj)) {
2965:                           $this->collImages->append($obj);
2966:                         }
2967:                       }
2968: 
2969:                       $this->collImagesPartial = true;
2970:                     }
2971: 
2972:                     $collImages->getInternalIterator()->rewind();
2973:                     return $collImages;
2974:                 }
2975: 
2976:                 if($partial && $this->collImages) {
2977:                     foreach($this->collImages as $obj) {
2978:                         if($obj->isNew()) {
2979:                             $collImages[] = $obj;
2980:                         }
2981:                     }
2982:                 }
2983: 
2984:                 $this->collImages = $collImages;
2985:                 $this->collImagesPartial = false;
2986:             }
2987:         }
2988: 
2989:         return $this->collImages;
2990:     }
2991: 
2992:     /**
2993:      * Sets a collection of Image objects related by a one-to-many relationship
2994:      * to the current object.
2995:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2996:      * and new objects from the given Propel collection.
2997:      *
2998:      * @param PropelCollection $images A Propel collection.
2999:      * @param PropelPDO $con Optional connection object
3000:      * @return Category The current object (for fluent API support)
3001:      */
3002:     public function setImages(PropelCollection $images, PropelPDO $con = null)
3003:     {
3004:         $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images);
3005: 
3006:         $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete));
3007: 
3008:         foreach ($imagesToDelete as $imageRemoved) {
3009:             $imageRemoved->setCategory(null);
3010:         }
3011: 
3012:         $this->collImages = null;
3013:         foreach ($images as $image) {
3014:             $this->addImage($image);
3015:         }
3016: 
3017:         $this->collImages = $images;
3018:         $this->collImagesPartial = false;
3019: 
3020:         return $this;
3021:     }
3022: 
3023:     /**
3024:      * Returns the number of related Image objects.
3025:      *
3026:      * @param Criteria $criteria
3027:      * @param boolean $distinct
3028:      * @param PropelPDO $con
3029:      * @return int             Count of related Image objects.
3030:      * @throws PropelException
3031:      */
3032:     public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3033:     {
3034:         $partial = $this->collImagesPartial && !$this->isNew();
3035:         if (null === $this->collImages || null !== $criteria || $partial) {
3036:             if ($this->isNew() && null === $this->collImages) {
3037:                 return 0;
3038:             }
3039: 
3040:             if($partial && !$criteria) {
3041:                 return count($this->getImages());
3042:             }
3043:             $query = ImageQuery::create(null, $criteria);
3044:             if ($distinct) {
3045:                 $query->distinct();
3046:             }
3047: 
3048:             return $query
3049:                 ->filterByCategory($this)
3050:                 ->count($con);
3051:         }
3052: 
3053:         return count($this->collImages);
3054:     }
3055: 
3056:     /**
3057:      * Method called to associate a Image object to this object
3058:      * through the Image foreign key attribute.
3059:      *
3060:      * @param    Image $l Image
3061:      * @return Category The current object (for fluent API support)
3062:      */
3063:     public function addImage(Image $l)
3064:     {
3065:         if ($this->collImages === null) {
3066:             $this->initImages();
3067:             $this->collImagesPartial = true;
3068:         }
3069:         if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
3070:             $this->doAddImage($l);
3071:         }
3072: 
3073:         return $this;
3074:     }
3075: 
3076:     /**
3077:      * @param   Image $image The image object to add.
3078:      */
3079:     protected function doAddImage($image)
3080:     {
3081:         $this->collImages[]= $image;
3082:         $image->setCategory($this);
3083:     }
3084: 
3085:     /**
3086:      * @param   Image $image The image object to remove.
3087:      * @return Category The current object (for fluent API support)
3088:      */
3089:     public function removeImage($image)
3090:     {
3091:         if ($this->getImages()->contains($image)) {
3092:             $this->collImages->remove($this->collImages->search($image));
3093:             if (null === $this->imagesScheduledForDeletion) {
3094:                 $this->imagesScheduledForDeletion = clone $this->collImages;
3095:                 $this->imagesScheduledForDeletion->clear();
3096:             }
3097:             $this->imagesScheduledForDeletion[]= $image;
3098:             $image->setCategory(null);
3099:         }
3100: 
3101:         return $this;
3102:     }
3103: 
3104: 
3105:     /**
3106:      * If this collection has already been initialized with
3107:      * an identical criteria, it returns the collection.
3108:      * Otherwise if this Category is new, it will return
3109:      * an empty collection; or if this Category has previously
3110:      * been saved, it will retrieve related Images from storage.
3111:      *
3112:      * This method is protected by default in order to keep the public
3113:      * api reasonable.  You can provide public methods for those you
3114:      * actually need in Category.
3115:      *
3116:      * @param Criteria $criteria optional Criteria object to narrow the query
3117:      * @param PropelPDO $con optional connection object
3118:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3119:      * @return PropelObjectCollection|Image[] List of Image objects
3120:      */
3121:     public function getImagesJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3122:     {
3123:         $query = ImageQuery::create(null, $criteria);
3124:         $query->joinWith('Product', $join_behavior);
3125: 
3126:         return $this->getImages($query, $con);
3127:     }
3128: 
3129: 
3130:     /**
3131:      * If this collection has already been initialized with
3132:      * an identical criteria, it returns the collection.
3133:      * Otherwise if this Category is new, it will return
3134:      * an empty collection; or if this Category has previously
3135:      * been saved, it will retrieve related Images from storage.
3136:      *
3137:      * This method is protected by default in order to keep the public
3138:      * api reasonable.  You can provide public methods for those you
3139:      * actually need in Category.
3140:      *
3141:      * @param Criteria $criteria optional Criteria object to narrow the query
3142:      * @param PropelPDO $con optional connection object
3143:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3144:      * @return PropelObjectCollection|Image[] List of Image objects
3145:      */
3146:     public function getImagesJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3147:     {
3148:         $query = ImageQuery::create(null, $criteria);
3149:         $query->joinWith('Content', $join_behavior);
3150: 
3151:         return $this->getImages($query, $con);
3152:     }
3153: 
3154: 
3155:     /**
3156:      * If this collection has already been initialized with
3157:      * an identical criteria, it returns the collection.
3158:      * Otherwise if this Category is new, it will return
3159:      * an empty collection; or if this Category has previously
3160:      * been saved, it will retrieve related Images from storage.
3161:      *
3162:      * This method is protected by default in order to keep the public
3163:      * api reasonable.  You can provide public methods for those you
3164:      * actually need in Category.
3165:      *
3166:      * @param Criteria $criteria optional Criteria object to narrow the query
3167:      * @param PropelPDO $con optional connection object
3168:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3169:      * @return PropelObjectCollection|Image[] List of Image objects
3170:      */
3171:     public function getImagesJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3172:     {
3173:         $query = ImageQuery::create(null, $criteria);
3174:         $query->joinWith('Folder', $join_behavior);
3175: 
3176:         return $this->getImages($query, $con);
3177:     }
3178: 
3179:     /**
3180:      * Clears out the collDocuments collection
3181:      *
3182:      * This does not modify the database; however, it will remove any associated objects, causing
3183:      * them to be refetched by subsequent calls to accessor method.
3184:      *
3185:      * @return Category The current object (for fluent API support)
3186:      * @see        addDocuments()
3187:      */
3188:     public function clearDocuments()
3189:     {
3190:         $this->collDocuments = null; // important to set this to null since that means it is uninitialized
3191:         $this->collDocumentsPartial = null;
3192: 
3193:         return $this;
3194:     }
3195: 
3196:     /**
3197:      * reset is the collDocuments collection loaded partially
3198:      *
3199:      * @return void
3200:      */
3201:     public function resetPartialDocuments($v = true)
3202:     {
3203:         $this->collDocumentsPartial = $v;
3204:     }
3205: 
3206:     /**
3207:      * Initializes the collDocuments collection.
3208:      *
3209:      * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments());
3210:      * however, you may wish to override this method in your stub class to provide setting appropriate
3211:      * to your application -- for example, setting the initial array to the values stored in database.
3212:      *
3213:      * @param boolean $overrideExisting If set to true, the method call initializes
3214:      *                                        the collection even if it is not empty
3215:      *
3216:      * @return void
3217:      */
3218:     public function initDocuments($overrideExisting = true)
3219:     {
3220:         if (null !== $this->collDocuments && !$overrideExisting) {
3221:             return;
3222:         }
3223:         $this->collDocuments = new PropelObjectCollection();
3224:         $this->collDocuments->setModel('Document');
3225:     }
3226: 
3227:     /**
3228:      * Gets an array of Document objects which contain a foreign key that references this object.
3229:      *
3230:      * If the $criteria is not null, it is used to always fetch the results from the database.
3231:      * Otherwise the results are fetched from the database the first time, then cached.
3232:      * Next time the same method is called without $criteria, the cached collection is returned.
3233:      * If this Category is new, it will return
3234:      * an empty collection or the current collection; the criteria is ignored on a new object.
3235:      *
3236:      * @param Criteria $criteria optional Criteria object to narrow the query
3237:      * @param PropelPDO $con optional connection object
3238:      * @return PropelObjectCollection|Document[] List of Document objects
3239:      * @throws PropelException
3240:      */
3241:     public function getDocuments($criteria = null, PropelPDO $con = null)
3242:     {
3243:         $partial = $this->collDocumentsPartial && !$this->isNew();
3244:         if (null === $this->collDocuments || null !== $criteria  || $partial) {
3245:             if ($this->isNew() && null === $this->collDocuments) {
3246:                 // return empty collection
3247:                 $this->initDocuments();
3248:             } else {
3249:                 $collDocuments = DocumentQuery::create(null, $criteria)
3250:                     ->filterByCategory($this)
3251:                     ->find($con);
3252:                 if (null !== $criteria) {
3253:                     if (false !== $this->collDocumentsPartial && count($collDocuments)) {
3254:                       $this->initDocuments(false);
3255: 
3256:                       foreach($collDocuments as $obj) {
3257:                         if (false == $this->collDocuments->contains($obj)) {
3258:                           $this->collDocuments->append($obj);
3259:                         }
3260:                       }
3261: 
3262:                       $this->collDocumentsPartial = true;
3263:                     }
3264: 
3265:                     $collDocuments->getInternalIterator()->rewind();
3266:                     return $collDocuments;
3267:                 }
3268: 
3269:                 if($partial && $this->collDocuments) {
3270:                     foreach($this->collDocuments as $obj) {
3271:                         if($obj->isNew()) {
3272:                             $collDocuments[] = $obj;
3273:                         }
3274:                     }
3275:                 }
3276: 
3277:                 $this->collDocuments = $collDocuments;
3278:                 $this->collDocumentsPartial = false;
3279:             }
3280:         }
3281: 
3282:         return $this->collDocuments;
3283:     }
3284: 
3285:     /**
3286:      * Sets a collection of Document objects related by a one-to-many relationship
3287:      * to the current object.
3288:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
3289:      * and new objects from the given Propel collection.
3290:      *
3291:      * @param PropelCollection $documents A Propel collection.
3292:      * @param PropelPDO $con Optional connection object
3293:      * @return Category The current object (for fluent API support)
3294:      */
3295:     public function setDocuments(PropelCollection $documents, PropelPDO $con = null)
3296:     {
3297:         $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents);
3298: 
3299:         $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete));
3300: 
3301:         foreach ($documentsToDelete as $documentRemoved) {
3302:             $documentRemoved->setCategory(null);
3303:         }
3304: 
3305:         $this->collDocuments = null;
3306:         foreach ($documents as $document) {
3307:             $this->addDocument($document);
3308:         }
3309: 
3310:         $this->collDocuments = $documents;
3311:         $this->collDocumentsPartial = false;
3312: 
3313:         return $this;
3314:     }
3315: 
3316:     /**
3317:      * Returns the number of related Document objects.
3318:      *
3319:      * @param Criteria $criteria
3320:      * @param boolean $distinct
3321:      * @param PropelPDO $con
3322:      * @return int             Count of related Document objects.
3323:      * @throws PropelException
3324:      */
3325:     public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3326:     {
3327:         $partial = $this->collDocumentsPartial && !$this->isNew();
3328:         if (null === $this->collDocuments || null !== $criteria || $partial) {
3329:             if ($this->isNew() && null === $this->collDocuments) {
3330:                 return 0;
3331:             }
3332: 
3333:             if($partial && !$criteria) {
3334:                 return count($this->getDocuments());
3335:             }
3336:             $query = DocumentQuery::create(null, $criteria);
3337:             if ($distinct) {
3338:                 $query->distinct();
3339:             }
3340: 
3341:             return $query
3342:                 ->filterByCategory($this)
3343:                 ->count($con);
3344:         }
3345: 
3346:         return count($this->collDocuments);
3347:     }
3348: 
3349:     /**
3350:      * Method called to associate a Document object to this object
3351:      * through the Document foreign key attribute.
3352:      *
3353:      * @param    Document $l Document
3354:      * @return Category The current object (for fluent API support)
3355:      */
3356:     public function addDocument(Document $l)
3357:     {
3358:         if ($this->collDocuments === null) {
3359:             $this->initDocuments();
3360:             $this->collDocumentsPartial = true;
3361:         }
3362:         if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
3363:             $this->doAddDocument($l);
3364:         }
3365: 
3366:         return $this;
3367:     }
3368: 
3369:     /**
3370:      * @param   Document $document The document object to add.
3371:      */
3372:     protected function doAddDocument($document)
3373:     {
3374:         $this->collDocuments[]= $document;
3375:         $document->setCategory($this);
3376:     }
3377: 
3378:     /**
3379:      * @param   Document $document The document object to remove.
3380:      * @return Category The current object (for fluent API support)
3381:      */
3382:     public function removeDocument($document)
3383:     {
3384:         if ($this->getDocuments()->contains($document)) {
3385:             $this->collDocuments->remove($this->collDocuments->search($document));
3386:             if (null === $this->documentsScheduledForDeletion) {
3387:                 $this->documentsScheduledForDeletion = clone $this->collDocuments;
3388:                 $this->documentsScheduledForDeletion->clear();
3389:             }
3390:             $this->documentsScheduledForDeletion[]= $document;
3391:             $document->setCategory(null);
3392:         }
3393: 
3394:         return $this;
3395:     }
3396: 
3397: 
3398:     /**
3399:      * If this collection has already been initialized with
3400:      * an identical criteria, it returns the collection.
3401:      * Otherwise if this Category is new, it will return
3402:      * an empty collection; or if this Category has previously
3403:      * been saved, it will retrieve related Documents from storage.
3404:      *
3405:      * This method is protected by default in order to keep the public
3406:      * api reasonable.  You can provide public methods for those you
3407:      * actually need in Category.
3408:      *
3409:      * @param Criteria $criteria optional Criteria object to narrow the query
3410:      * @param PropelPDO $con optional connection object
3411:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3412:      * @return PropelObjectCollection|Document[] List of Document objects
3413:      */
3414:     public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3415:     {
3416:         $query = DocumentQuery::create(null, $criteria);
3417:         $query->joinWith('Product', $join_behavior);
3418: 
3419:         return $this->getDocuments($query, $con);
3420:     }
3421: 
3422: 
3423:     /**
3424:      * If this collection has already been initialized with
3425:      * an identical criteria, it returns the collection.
3426:      * Otherwise if this Category is new, it will return
3427:      * an empty collection; or if this Category has previously
3428:      * been saved, it will retrieve related Documents from storage.
3429:      *
3430:      * This method is protected by default in order to keep the public
3431:      * api reasonable.  You can provide public methods for those you
3432:      * actually need in Category.
3433:      *
3434:      * @param Criteria $criteria optional Criteria object to narrow the query
3435:      * @param PropelPDO $con optional connection object
3436:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3437:      * @return PropelObjectCollection|Document[] List of Document objects
3438:      */
3439:     public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3440:     {
3441:         $query = DocumentQuery::create(null, $criteria);
3442:         $query->joinWith('Content', $join_behavior);
3443: 
3444:         return $this->getDocuments($query, $con);
3445:     }
3446: 
3447: 
3448:     /**
3449:      * If this collection has already been initialized with
3450:      * an identical criteria, it returns the collection.
3451:      * Otherwise if this Category is new, it will return
3452:      * an empty collection; or if this Category has previously
3453:      * been saved, it will retrieve related Documents from storage.
3454:      *
3455:      * This method is protected by default in order to keep the public
3456:      * api reasonable.  You can provide public methods for those you
3457:      * actually need in Category.
3458:      *
3459:      * @param Criteria $criteria optional Criteria object to narrow the query
3460:      * @param PropelPDO $con optional connection object
3461:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3462:      * @return PropelObjectCollection|Document[] List of Document objects
3463:      */
3464:     public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3465:     {
3466:         $query = DocumentQuery::create(null, $criteria);
3467:         $query->joinWith('Folder', $join_behavior);
3468: 
3469:         return $this->getDocuments($query, $con);
3470:     }
3471: 
3472:     /**
3473:      * Clears out the collRewritings collection
3474:      *
3475:      * This does not modify the database; however, it will remove any associated objects, causing
3476:      * them to be refetched by subsequent calls to accessor method.
3477:      *
3478:      * @return Category The current object (for fluent API support)
3479:      * @see        addRewritings()
3480:      */
3481:     public function clearRewritings()
3482:     {
3483:         $this->collRewritings = null; // important to set this to null since that means it is uninitialized
3484:         $this->collRewritingsPartial = null;
3485: 
3486:         return $this;
3487:     }
3488: 
3489:     /**
3490:      * reset is the collRewritings collection loaded partially
3491:      *
3492:      * @return void
3493:      */
3494:     public function resetPartialRewritings($v = true)
3495:     {
3496:         $this->collRewritingsPartial = $v;
3497:     }
3498: 
3499:     /**
3500:      * Initializes the collRewritings collection.
3501:      *
3502:      * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings());
3503:      * however, you may wish to override this method in your stub class to provide setting appropriate
3504:      * to your application -- for example, setting the initial array to the values stored in database.
3505:      *
3506:      * @param boolean $overrideExisting If set to true, the method call initializes
3507:      *                                        the collection even if it is not empty
3508:      *
3509:      * @return void
3510:      */
3511:     public function initRewritings($overrideExisting = true)
3512:     {
3513:         if (null !== $this->collRewritings && !$overrideExisting) {
3514:             return;
3515:         }
3516:         $this->collRewritings = new PropelObjectCollection();
3517:         $this->collRewritings->setModel('Rewriting');
3518:     }
3519: 
3520:     /**
3521:      * Gets an array of Rewriting objects which contain a foreign key that references this object.
3522:      *
3523:      * If the $criteria is not null, it is used to always fetch the results from the database.
3524:      * Otherwise the results are fetched from the database the first time, then cached.
3525:      * Next time the same method is called without $criteria, the cached collection is returned.
3526:      * If this Category is new, it will return
3527:      * an empty collection or the current collection; the criteria is ignored on a new object.
3528:      *
3529:      * @param Criteria $criteria optional Criteria object to narrow the query
3530:      * @param PropelPDO $con optional connection object
3531:      * @return PropelObjectCollection|Rewriting[] List of Rewriting objects
3532:      * @throws PropelException
3533:      */
3534:     public function getRewritings($criteria = null, PropelPDO $con = null)
3535:     {
3536:         $partial = $this->collRewritingsPartial && !$this->isNew();
3537:         if (null === $this->collRewritings || null !== $criteria  || $partial) {
3538:             if ($this->isNew() && null === $this->collRewritings) {
3539:                 // return empty collection
3540:                 $this->initRewritings();
3541:             } else {
3542:                 $collRewritings = RewritingQuery::create(null, $criteria)
3543:                     ->filterByCategory($this)
3544:                     ->find($con);
3545:                 if (null !== $criteria) {
3546:                     if (false !== $this->collRewritingsPartial && count($collRewritings)) {
3547:                       $this->initRewritings(false);
3548: 
3549:                       foreach($collRewritings as $obj) {
3550:                         if (false == $this->collRewritings->contains($obj)) {
3551:                           $this->collRewritings->append($obj);
3552:                         }
3553:                       }
3554: 
3555:                       $this->collRewritingsPartial = true;
3556:                     }
3557: 
3558:                     $collRewritings->getInternalIterator()->rewind();
3559:                     return $collRewritings;
3560:                 }
3561: 
3562:                 if($partial && $this->collRewritings) {
3563:                     foreach($this->collRewritings as $obj) {
3564:                         if($obj->isNew()) {
3565:                             $collRewritings[] = $obj;
3566:                         }
3567:                     }
3568:                 }
3569: 
3570:                 $this->collRewritings = $collRewritings;
3571:                 $this->collRewritingsPartial = false;
3572:             }
3573:         }
3574: 
3575:         return $this->collRewritings;
3576:     }
3577: 
3578:     /**
3579:      * Sets a collection of Rewriting objects related by a one-to-many relationship
3580:      * to the current object.
3581:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
3582:      * and new objects from the given Propel collection.
3583:      *
3584:      * @param PropelCollection $rewritings A Propel collection.
3585:      * @param PropelPDO $con Optional connection object
3586:      * @return Category The current object (for fluent API support)
3587:      */
3588:     public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null)
3589:     {
3590:         $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings);
3591: 
3592:         $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete));
3593: 
3594:         foreach ($rewritingsToDelete as $rewritingRemoved) {
3595:             $rewritingRemoved->setCategory(null);
3596:         }
3597: 
3598:         $this->collRewritings = null;
3599:         foreach ($rewritings as $rewriting) {
3600:             $this->addRewriting($rewriting);
3601:         }
3602: 
3603:         $this->collRewritings = $rewritings;
3604:         $this->collRewritingsPartial = false;
3605: 
3606:         return $this;
3607:     }
3608: 
3609:     /**
3610:      * Returns the number of related Rewriting objects.
3611:      *
3612:      * @param Criteria $criteria
3613:      * @param boolean $distinct
3614:      * @param PropelPDO $con
3615:      * @return int             Count of related Rewriting objects.
3616:      * @throws PropelException
3617:      */
3618:     public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3619:     {
3620:         $partial = $this->collRewritingsPartial && !$this->isNew();
3621:         if (null === $this->collRewritings || null !== $criteria || $partial) {
3622:             if ($this->isNew() && null === $this->collRewritings) {
3623:                 return 0;
3624:             }
3625: 
3626:             if($partial && !$criteria) {
3627:                 return count($this->getRewritings());
3628:             }
3629:             $query = RewritingQuery::create(null, $criteria);
3630:             if ($distinct) {
3631:                 $query->distinct();
3632:             }
3633: 
3634:             return $query
3635:                 ->filterByCategory($this)
3636:                 ->count($con);
3637:         }
3638: 
3639:         return count($this->collRewritings);
3640:     }
3641: 
3642:     /**
3643:      * Method called to associate a Rewriting object to this object
3644:      * through the Rewriting foreign key attribute.
3645:      *
3646:      * @param    Rewriting $l Rewriting
3647:      * @return Category The current object (for fluent API support)
3648:      */
3649:     public function addRewriting(Rewriting $l)
3650:     {
3651:         if ($this->collRewritings === null) {
3652:             $this->initRewritings();
3653:             $this->collRewritingsPartial = true;
3654:         }
3655:         if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
3656:             $this->doAddRewriting($l);
3657:         }
3658: 
3659:         return $this;
3660:     }
3661: 
3662:     /**
3663:      * @param   Rewriting $rewriting The rewriting object to add.
3664:      */
3665:     protected function doAddRewriting($rewriting)
3666:     {
3667:         $this->collRewritings[]= $rewriting;
3668:         $rewriting->setCategory($this);
3669:     }
3670: 
3671:     /**
3672:      * @param   Rewriting $rewriting The rewriting object to remove.
3673:      * @return Category The current object (for fluent API support)
3674:      */
3675:     public function removeRewriting($rewriting)
3676:     {
3677:         if ($this->getRewritings()->contains($rewriting)) {
3678:             $this->collRewritings->remove($this->collRewritings->search($rewriting));
3679:             if (null === $this->rewritingsScheduledForDeletion) {
3680:                 $this->rewritingsScheduledForDeletion = clone $this->collRewritings;
3681:                 $this->rewritingsScheduledForDeletion->clear();
3682:             }
3683:             $this->rewritingsScheduledForDeletion[]= $rewriting;
3684:             $rewriting->setCategory(null);
3685:         }
3686: 
3687:         return $this;
3688:     }
3689: 
3690: 
3691:     /**
3692:      * If this collection has already been initialized with
3693:      * an identical criteria, it returns the collection.
3694:      * Otherwise if this Category is new, it will return
3695:      * an empty collection; or if this Category has previously
3696:      * been saved, it will retrieve related Rewritings from storage.
3697:      *
3698:      * This method is protected by default in order to keep the public
3699:      * api reasonable.  You can provide public methods for those you
3700:      * actually need in Category.
3701:      *
3702:      * @param Criteria $criteria optional Criteria object to narrow the query
3703:      * @param PropelPDO $con optional connection object
3704:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3705:      * @return PropelObjectCollection|Rewriting[] List of Rewriting objects
3706:      */
3707:     public function getRewritingsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3708:     {
3709:         $query = RewritingQuery::create(null, $criteria);
3710:         $query->joinWith('Product', $join_behavior);
3711: 
3712:         return $this->getRewritings($query, $con);
3713:     }
3714: 
3715: 
3716:     /**
3717:      * If this collection has already been initialized with
3718:      * an identical criteria, it returns the collection.
3719:      * Otherwise if this Category is new, it will return
3720:      * an empty collection; or if this Category has previously
3721:      * been saved, it will retrieve related Rewritings from storage.
3722:      *
3723:      * This method is protected by default in order to keep the public
3724:      * api reasonable.  You can provide public methods for those you
3725:      * actually need in Category.
3726:      *
3727:      * @param Criteria $criteria optional Criteria object to narrow the query
3728:      * @param PropelPDO $con optional connection object
3729:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3730:      * @return PropelObjectCollection|Rewriting[] List of Rewriting objects
3731:      */
3732:     public function getRewritingsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3733:     {
3734:         $query = RewritingQuery::create(null, $criteria);
3735:         $query->joinWith('Folder', $join_behavior);
3736: 
3737:         return $this->getRewritings($query, $con);
3738:     }
3739: 
3740: 
3741:     /**
3742:      * If this collection has already been initialized with
3743:      * an identical criteria, it returns the collection.
3744:      * Otherwise if this Category is new, it will return
3745:      * an empty collection; or if this Category has previously
3746:      * been saved, it will retrieve related Rewritings from storage.
3747:      *
3748:      * This method is protected by default in order to keep the public
3749:      * api reasonable.  You can provide public methods for those you
3750:      * actually need in Category.
3751:      *
3752:      * @param Criteria $criteria optional Criteria object to narrow the query
3753:      * @param PropelPDO $con optional connection object
3754:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3755:      * @return PropelObjectCollection|Rewriting[] List of Rewriting objects
3756:      */
3757:     public function getRewritingsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3758:     {
3759:         $query = RewritingQuery::create(null, $criteria);
3760:         $query->joinWith('Content', $join_behavior);
3761: 
3762:         return $this->getRewritings($query, $con);
3763:     }
3764: 
3765:     /**
3766:      * Clears out the collCategoryI18ns collection
3767:      *
3768:      * This does not modify the database; however, it will remove any associated objects, causing
3769:      * them to be refetched by subsequent calls to accessor method.
3770:      *
3771:      * @return Category The current object (for fluent API support)
3772:      * @see        addCategoryI18ns()
3773:      */
3774:     public function clearCategoryI18ns()
3775:     {
3776:         $this->collCategoryI18ns = null; // important to set this to null since that means it is uninitialized
3777:         $this->collCategoryI18nsPartial = null;
3778: 
3779:         return $this;
3780:     }
3781: 
3782:     /**
3783:      * reset is the collCategoryI18ns collection loaded partially
3784:      *
3785:      * @return void
3786:      */
3787:     public function resetPartialCategoryI18ns($v = true)
3788:     {
3789:         $this->collCategoryI18nsPartial = $v;
3790:     }
3791: 
3792:     /**
3793:      * Initializes the collCategoryI18ns collection.
3794:      *
3795:      * By default this just sets the collCategoryI18ns collection to an empty array (like clearcollCategoryI18ns());
3796:      * however, you may wish to override this method in your stub class to provide setting appropriate
3797:      * to your application -- for example, setting the initial array to the values stored in database.
3798:      *
3799:      * @param boolean $overrideExisting If set to true, the method call initializes
3800:      *                                        the collection even if it is not empty
3801:      *
3802:      * @return void
3803:      */
3804:     public function initCategoryI18ns($overrideExisting = true)
3805:     {
3806:         if (null !== $this->collCategoryI18ns && !$overrideExisting) {
3807:             return;
3808:         }
3809:         $this->collCategoryI18ns = new PropelObjectCollection();
3810:         $this->collCategoryI18ns->setModel('CategoryI18n');
3811:     }
3812: 
3813:     /**
3814:      * Gets an array of CategoryI18n objects which contain a foreign key that references this object.
3815:      *
3816:      * If the $criteria is not null, it is used to always fetch the results from the database.
3817:      * Otherwise the results are fetched from the database the first time, then cached.
3818:      * Next time the same method is called without $criteria, the cached collection is returned.
3819:      * If this Category is new, it will return
3820:      * an empty collection or the current collection; the criteria is ignored on a new object.
3821:      *
3822:      * @param Criteria $criteria optional Criteria object to narrow the query
3823:      * @param PropelPDO $con optional connection object
3824:      * @return PropelObjectCollection|CategoryI18n[] List of CategoryI18n objects
3825:      * @throws PropelException
3826:      */
3827:     public function getCategoryI18ns($criteria = null, PropelPDO $con = null)
3828:     {
3829:         $partial = $this->collCategoryI18nsPartial && !$this->isNew();
3830:         if (null === $this->collCategoryI18ns || null !== $criteria  || $partial) {
3831:             if ($this->isNew() && null === $this->collCategoryI18ns) {
3832:                 // return empty collection
3833:                 $this->initCategoryI18ns();
3834:             } else {
3835:                 $collCategoryI18ns = CategoryI18nQuery::create(null, $criteria)
3836:                     ->filterByCategory($this)
3837:                     ->find($con);
3838:                 if (null !== $criteria) {
3839:                     if (false !== $this->collCategoryI18nsPartial && count($collCategoryI18ns)) {
3840:                       $this->initCategoryI18ns(false);
3841: 
3842:                       foreach($collCategoryI18ns as $obj) {
3843:                         if (false == $this->collCategoryI18ns->contains($obj)) {
3844:                           $this->collCategoryI18ns->append($obj);
3845:                         }
3846:                       }
3847: 
3848:                       $this->collCategoryI18nsPartial = true;
3849:                     }
3850: 
3851:                     $collCategoryI18ns->getInternalIterator()->rewind();
3852:                     return $collCategoryI18ns;
3853:                 }
3854: 
3855:                 if($partial && $this->collCategoryI18ns) {
3856:                     foreach($this->collCategoryI18ns as $obj) {
3857:                         if($obj->isNew()) {
3858:                             $collCategoryI18ns[] = $obj;
3859:                         }
3860:                     }
3861:                 }
3862: 
3863:                 $this->collCategoryI18ns = $collCategoryI18ns;
3864:                 $this->collCategoryI18nsPartial = false;
3865:             }
3866:         }
3867: 
3868:         return $this->collCategoryI18ns;
3869:     }
3870: 
3871:     /**
3872:      * Sets a collection of CategoryI18n objects related by a one-to-many relationship
3873:      * to the current object.
3874:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
3875:      * and new objects from the given Propel collection.
3876:      *
3877:      * @param PropelCollection $categoryI18ns A Propel collection.
3878:      * @param PropelPDO $con Optional connection object
3879:      * @return Category The current object (for fluent API support)
3880:      */
3881:     public function setCategoryI18ns(PropelCollection $categoryI18ns, PropelPDO $con = null)
3882:     {
3883:         $categoryI18nsToDelete = $this->getCategoryI18ns(new Criteria(), $con)->diff($categoryI18ns);
3884: 
3885:         $this->categoryI18nsScheduledForDeletion = unserialize(serialize($categoryI18nsToDelete));
3886: 
3887:         foreach ($categoryI18nsToDelete as $categoryI18nRemoved) {
3888:             $categoryI18nRemoved->setCategory(null);
3889:         }
3890: 
3891:         $this->collCategoryI18ns = null;
3892:         foreach ($categoryI18ns as $categoryI18n) {
3893:             $this->addCategoryI18n($categoryI18n);
3894:         }
3895: 
3896:         $this->collCategoryI18ns = $categoryI18ns;
3897:         $this->collCategoryI18nsPartial = false;
3898: 
3899:         return $this;
3900:     }
3901: 
3902:     /**
3903:      * Returns the number of related CategoryI18n objects.
3904:      *
3905:      * @param Criteria $criteria
3906:      * @param boolean $distinct
3907:      * @param PropelPDO $con
3908:      * @return int             Count of related CategoryI18n objects.
3909:      * @throws PropelException
3910:      */
3911:     public function countCategoryI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3912:     {
3913:         $partial = $this->collCategoryI18nsPartial && !$this->isNew();
3914:         if (null === $this->collCategoryI18ns || null !== $criteria || $partial) {
3915:             if ($this->isNew() && null === $this->collCategoryI18ns) {
3916:                 return 0;
3917:             }
3918: 
3919:             if($partial && !$criteria) {
3920:                 return count($this->getCategoryI18ns());
3921:             }
3922:             $query = CategoryI18nQuery::create(null, $criteria);
3923:             if ($distinct) {
3924:                 $query->distinct();
3925:             }
3926: 
3927:             return $query
3928:                 ->filterByCategory($this)
3929:                 ->count($con);
3930:         }
3931: 
3932:         return count($this->collCategoryI18ns);
3933:     }
3934: 
3935:     /**
3936:      * Method called to associate a CategoryI18n object to this object
3937:      * through the CategoryI18n foreign key attribute.
3938:      *
3939:      * @param    CategoryI18n $l CategoryI18n
3940:      * @return Category The current object (for fluent API support)
3941:      */
3942:     public function addCategoryI18n(CategoryI18n $l)
3943:     {
3944:         if ($l && $locale = $l->getLocale()) {
3945:             $this->setLocale($locale);
3946:             $this->currentTranslations[$locale] = $l;
3947:         }
3948:         if ($this->collCategoryI18ns === null) {
3949:             $this->initCategoryI18ns();
3950:             $this->collCategoryI18nsPartial = true;
3951:         }
3952:         if (!in_array($l, $this->collCategoryI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
3953:             $this->doAddCategoryI18n($l);
3954:         }
3955: 
3956:         return $this;
3957:     }
3958: 
3959:     /**
3960:      * @param   CategoryI18n $categoryI18n The categoryI18n object to add.
3961:      */
3962:     protected function doAddCategoryI18n($categoryI18n)
3963:     {
3964:         $this->collCategoryI18ns[]= $categoryI18n;
3965:         $categoryI18n->setCategory($this);
3966:     }
3967: 
3968:     /**
3969:      * @param   CategoryI18n $categoryI18n The categoryI18n object to remove.
3970:      * @return Category The current object (for fluent API support)
3971:      */
3972:     public function removeCategoryI18n($categoryI18n)
3973:     {
3974:         if ($this->getCategoryI18ns()->contains($categoryI18n)) {
3975:             $this->collCategoryI18ns->remove($this->collCategoryI18ns->search($categoryI18n));
3976:             if (null === $this->categoryI18nsScheduledForDeletion) {
3977:                 $this->categoryI18nsScheduledForDeletion = clone $this->collCategoryI18ns;
3978:                 $this->categoryI18nsScheduledForDeletion->clear();
3979:             }
3980:             $this->categoryI18nsScheduledForDeletion[]= clone $categoryI18n;
3981:             $categoryI18n->setCategory(null);
3982:         }
3983: 
3984:         return $this;
3985:     }
3986: 
3987:     /**
3988:      * Clears out the collCategoryVersions collection
3989:      *
3990:      * This does not modify the database; however, it will remove any associated objects, causing
3991:      * them to be refetched by subsequent calls to accessor method.
3992:      *
3993:      * @return Category The current object (for fluent API support)
3994:      * @see        addCategoryVersions()
3995:      */
3996:     public function clearCategoryVersions()
3997:     {
3998:         $this->collCategoryVersions = null; // important to set this to null since that means it is uninitialized
3999:         $this->collCategoryVersionsPartial = null;
4000: 
4001:         return $this;
4002:     }
4003: 
4004:     /**
4005:      * reset is the collCategoryVersions collection loaded partially
4006:      *
4007:      * @return void
4008:      */
4009:     public function resetPartialCategoryVersions($v = true)
4010:     {
4011:         $this->collCategoryVersionsPartial = $v;
4012:     }
4013: 
4014:     /**
4015:      * Initializes the collCategoryVersions collection.
4016:      *
4017:      * By default this just sets the collCategoryVersions collection to an empty array (like clearcollCategoryVersions());
4018:      * however, you may wish to override this method in your stub class to provide setting appropriate
4019:      * to your application -- for example, setting the initial array to the values stored in database.
4020:      *
4021:      * @param boolean $overrideExisting If set to true, the method call initializes
4022:      *                                        the collection even if it is not empty
4023:      *
4024:      * @return void
4025:      */
4026:     public function initCategoryVersions($overrideExisting = true)
4027:     {
4028:         if (null !== $this->collCategoryVersions && !$overrideExisting) {
4029:             return;
4030:         }
4031:         $this->collCategoryVersions = new PropelObjectCollection();
4032:         $this->collCategoryVersions->setModel('CategoryVersion');
4033:     }
4034: 
4035:     /**
4036:      * Gets an array of CategoryVersion objects which contain a foreign key that references this object.
4037:      *
4038:      * If the $criteria is not null, it is used to always fetch the results from the database.
4039:      * Otherwise the results are fetched from the database the first time, then cached.
4040:      * Next time the same method is called without $criteria, the cached collection is returned.
4041:      * If this Category is new, it will return
4042:      * an empty collection or the current collection; the criteria is ignored on a new object.
4043:      *
4044:      * @param Criteria $criteria optional Criteria object to narrow the query
4045:      * @param PropelPDO $con optional connection object
4046:      * @return PropelObjectCollection|CategoryVersion[] List of CategoryVersion objects
4047:      * @throws PropelException
4048:      */
4049:     public function getCategoryVersions($criteria = null, PropelPDO $con = null)
4050:     {
4051:         $partial = $this->collCategoryVersionsPartial && !$this->isNew();
4052:         if (null === $this->collCategoryVersions || null !== $criteria  || $partial) {
4053:             if ($this->isNew() && null === $this->collCategoryVersions) {
4054:                 // return empty collection
4055:                 $this->initCategoryVersions();
4056:             } else {
4057:                 $collCategoryVersions = CategoryVersionQuery::create(null, $criteria)
4058:                     ->filterByCategory($this)
4059:                     ->find($con);
4060:                 if (null !== $criteria) {
4061:                     if (false !== $this->collCategoryVersionsPartial && count($collCategoryVersions)) {
4062:                       $this->initCategoryVersions(false);
4063: 
4064:                       foreach($collCategoryVersions as $obj) {
4065:                         if (false == $this->collCategoryVersions->contains($obj)) {
4066:                           $this->collCategoryVersions->append($obj);
4067:                         }
4068:                       }
4069: 
4070:                       $this->collCategoryVersionsPartial = true;
4071:                     }
4072: 
4073:                     $collCategoryVersions->getInternalIterator()->rewind();
4074:                     return $collCategoryVersions;
4075:                 }
4076: 
4077:                 if($partial && $this->collCategoryVersions) {
4078:                     foreach($this->collCategoryVersions as $obj) {
4079:                         if($obj->isNew()) {
4080:                             $collCategoryVersions[] = $obj;
4081:                         }
4082:                     }
4083:                 }
4084: 
4085:                 $this->collCategoryVersions = $collCategoryVersions;
4086:                 $this->collCategoryVersionsPartial = false;
4087:             }
4088:         }
4089: 
4090:         return $this->collCategoryVersions;
4091:     }
4092: 
4093:     /**
4094:      * Sets a collection of CategoryVersion objects related by a one-to-many relationship
4095:      * to the current object.
4096:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
4097:      * and new objects from the given Propel collection.
4098:      *
4099:      * @param PropelCollection $categoryVersions A Propel collection.
4100:      * @param PropelPDO $con Optional connection object
4101:      * @return Category The current object (for fluent API support)
4102:      */
4103:     public function setCategoryVersions(PropelCollection $categoryVersions, PropelPDO $con = null)
4104:     {
4105:         $categoryVersionsToDelete = $this->getCategoryVersions(new Criteria(), $con)->diff($categoryVersions);
4106: 
4107:         $this->categoryVersionsScheduledForDeletion = unserialize(serialize($categoryVersionsToDelete));
4108: 
4109:         foreach ($categoryVersionsToDelete as $categoryVersionRemoved) {
4110:             $categoryVersionRemoved->setCategory(null);
4111:         }
4112: 
4113:         $this->collCategoryVersions = null;
4114:         foreach ($categoryVersions as $categoryVersion) {
4115:             $this->addCategoryVersion($categoryVersion);
4116:         }
4117: 
4118:         $this->collCategoryVersions = $categoryVersions;
4119:         $this->collCategoryVersionsPartial = false;
4120: 
4121:         return $this;
4122:     }
4123: 
4124:     /**
4125:      * Returns the number of related CategoryVersion objects.
4126:      *
4127:      * @param Criteria $criteria
4128:      * @param boolean $distinct
4129:      * @param PropelPDO $con
4130:      * @return int             Count of related CategoryVersion objects.
4131:      * @throws PropelException
4132:      */
4133:     public function countCategoryVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
4134:     {
4135:         $partial = $this->collCategoryVersionsPartial && !$this->isNew();
4136:         if (null === $this->collCategoryVersions || null !== $criteria || $partial) {
4137:             if ($this->isNew() && null === $this->collCategoryVersions) {
4138:                 return 0;
4139:             }
4140: 
4141:             if($partial && !$criteria) {
4142:                 return count($this->getCategoryVersions());
4143:             }
4144:             $query = CategoryVersionQuery::create(null, $criteria);
4145:             if ($distinct) {
4146:                 $query->distinct();
4147:             }
4148: 
4149:             return $query
4150:                 ->filterByCategory($this)
4151:                 ->count($con);
4152:         }
4153: 
4154:         return count($this->collCategoryVersions);
4155:     }
4156: 
4157:     /**
4158:      * Method called to associate a CategoryVersion object to this object
4159:      * through the CategoryVersion foreign key attribute.
4160:      *
4161:      * @param    CategoryVersion $l CategoryVersion
4162:      * @return Category The current object (for fluent API support)
4163:      */
4164:     public function addCategoryVersion(CategoryVersion $l)
4165:     {
4166:         if ($this->collCategoryVersions === null) {
4167:             $this->initCategoryVersions();
4168:             $this->collCategoryVersionsPartial = true;
4169:         }
4170:         if (!in_array($l, $this->collCategoryVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
4171:             $this->doAddCategoryVersion($l);
4172:         }
4173: 
4174:         return $this;
4175:     }
4176: 
4177:     /**
4178:      * @param   CategoryVersion $categoryVersion The categoryVersion object to add.
4179:      */
4180:     protected function doAddCategoryVersion($categoryVersion)
4181:     {
4182:         $this->collCategoryVersions[]= $categoryVersion;
4183:         $categoryVersion->setCategory($this);
4184:     }
4185: 
4186:     /**
4187:      * @param   CategoryVersion $categoryVersion The categoryVersion object to remove.
4188:      * @return Category The current object (for fluent API support)
4189:      */
4190:     public function removeCategoryVersion($categoryVersion)
4191:     {
4192:         if ($this->getCategoryVersions()->contains($categoryVersion)) {
4193:             $this->collCategoryVersions->remove($this->collCategoryVersions->search($categoryVersion));
4194:             if (null === $this->categoryVersionsScheduledForDeletion) {
4195:                 $this->categoryVersionsScheduledForDeletion = clone $this->collCategoryVersions;
4196:                 $this->categoryVersionsScheduledForDeletion->clear();
4197:             }
4198:             $this->categoryVersionsScheduledForDeletion[]= clone $categoryVersion;
4199:             $categoryVersion->setCategory(null);
4200:         }
4201: 
4202:         return $this;
4203:     }
4204: 
4205:     /**
4206:      * Clears the current object and sets all attributes to their default values
4207:      */
4208:     public function clear()
4209:     {
4210:         $this->id = null;
4211:         $this->parent = null;
4212:         $this->link = null;
4213:         $this->visible = null;
4214:         $this->position = null;
4215:         $this->created_at = null;
4216:         $this->updated_at = null;
4217:         $this->version = null;
4218:         $this->version_created_at = null;
4219:         $this->version_created_by = null;
4220:         $this->alreadyInSave = false;
4221:         $this->alreadyInValidation = false;
4222:         $this->alreadyInClearAllReferencesDeep = false;
4223:         $this->clearAllReferences();
4224:         $this->applyDefaultValues();
4225:         $this->resetModified();
4226:         $this->setNew(true);
4227:         $this->setDeleted(false);
4228:     }
4229: 
4230:     /**
4231:      * Resets all references to other model objects or collections of model objects.
4232:      *
4233:      * This method is a user-space workaround for PHP's inability to garbage collect
4234:      * objects with circular references (even in PHP 5.3). This is currently necessary
4235:      * when using Propel in certain daemon or large-volumne/high-memory operations.
4236:      *
4237:      * @param boolean $deep Whether to also clear the references on all referrer objects.
4238:      */
4239:     public function clearAllReferences($deep = false)
4240:     {
4241:         if ($deep && !$this->alreadyInClearAllReferencesDeep) {
4242:             $this->alreadyInClearAllReferencesDeep = true;
4243:             if ($this->collProductCategorys) {
4244:                 foreach ($this->collProductCategorys as $o) {
4245:                     $o->clearAllReferences($deep);
4246:                 }
4247:             }
4248:             if ($this->collFeatureCategorys) {
4249:                 foreach ($this->collFeatureCategorys as $o) {
4250:                     $o->clearAllReferences($deep);
4251:                 }
4252:             }
4253:             if ($this->collAttributeCategorys) {
4254:                 foreach ($this->collAttributeCategorys as $o) {
4255:                     $o->clearAllReferences($deep);
4256:                 }
4257:             }
4258:             if ($this->collContentAssocs) {
4259:                 foreach ($this->collContentAssocs as $o) {
4260:                     $o->clearAllReferences($deep);
4261:                 }
4262:             }
4263:             if ($this->collImages) {
4264:                 foreach ($this->collImages as $o) {
4265:                     $o->clearAllReferences($deep);
4266:                 }
4267:             }
4268:             if ($this->collDocuments) {
4269:                 foreach ($this->collDocuments as $o) {
4270:                     $o->clearAllReferences($deep);
4271:                 }
4272:             }
4273:             if ($this->collRewritings) {
4274:                 foreach ($this->collRewritings as $o) {
4275:                     $o->clearAllReferences($deep);
4276:                 }
4277:             }
4278:             if ($this->collCategoryI18ns) {
4279:                 foreach ($this->collCategoryI18ns as $o) {
4280:                     $o->clearAllReferences($deep);
4281:                 }
4282:             }
4283:             if ($this->collCategoryVersions) {
4284:                 foreach ($this->collCategoryVersions as $o) {
4285:                     $o->clearAllReferences($deep);
4286:                 }
4287:             }
4288: 
4289:             $this->alreadyInClearAllReferencesDeep = false;
4290:         } // if ($deep)
4291: 
4292:         // i18n behavior
4293:         $this->currentLocale = 'en_US';
4294:         $this->currentTranslations = null;
4295: 
4296:         if ($this->collProductCategorys instanceof PropelCollection) {
4297:             $this->collProductCategorys->clearIterator();
4298:         }
4299:         $this->collProductCategorys = null;
4300:         if ($this->collFeatureCategorys instanceof PropelCollection) {
4301:             $this->collFeatureCategorys->clearIterator();
4302:         }
4303:         $this->collFeatureCategorys = null;
4304:         if ($this->collAttributeCategorys instanceof PropelCollection) {
4305:             $this->collAttributeCategorys->clearIterator();
4306:         }
4307:         $this->collAttributeCategorys = null;
4308:         if ($this->collContentAssocs instanceof PropelCollection) {
4309:             $this->collContentAssocs->clearIterator();
4310:         }
4311:         $this->collContentAssocs = null;
4312:         if ($this->collImages instanceof PropelCollection) {
4313:             $this->collImages->clearIterator();
4314:         }
4315:         $this->collImages = null;
4316:         if ($this->collDocuments instanceof PropelCollection) {
4317:             $this->collDocuments->clearIterator();
4318:         }
4319:         $this->collDocuments = null;
4320:         if ($this->collRewritings instanceof PropelCollection) {
4321:             $this->collRewritings->clearIterator();
4322:         }
4323:         $this->collRewritings = null;
4324:         if ($this->collCategoryI18ns instanceof PropelCollection) {
4325:             $this->collCategoryI18ns->clearIterator();
4326:         }
4327:         $this->collCategoryI18ns = null;
4328:         if ($this->collCategoryVersions instanceof PropelCollection) {
4329:             $this->collCategoryVersions->clearIterator();
4330:         }
4331:         $this->collCategoryVersions = null;
4332:     }
4333: 
4334:     /**
4335:      * return the string representation of this object
4336:      *
4337:      * @return string
4338:      */
4339:     public function __toString()
4340:     {
4341:         return (string) $this->exportTo(CategoryPeer::DEFAULT_STRING_FORMAT);
4342:     }
4343: 
4344:     /**
4345:      * return true is the object is in saving state
4346:      *
4347:      * @return boolean
4348:      */
4349:     public function isAlreadyInSave()
4350:     {
4351:         return $this->alreadyInSave;
4352:     }
4353: 
4354:     // timestampable behavior
4355: 
4356:     /**
4357:      * Mark the current object so that the update date doesn't get updated during next save
4358:      *
4359:      * @return     Category The current object (for fluent API support)
4360:      */
4361:     public function keepUpdateDateUnchanged()
4362:     {
4363:         $this->modifiedColumns[] = CategoryPeer::UPDATED_AT;
4364: 
4365:         return $this;
4366:     }
4367: 
4368:     // i18n behavior
4369: 
4370:     /**
4371:      * Sets the locale for translations
4372:      *
4373:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
4374:      *
4375:      * @return    Category The current object (for fluent API support)
4376:      */
4377:     public function setLocale($locale = 'en_US')
4378:     {
4379:         $this->currentLocale = $locale;
4380: 
4381:         return $this;
4382:     }
4383: 
4384:     /**
4385:      * Gets the locale for translations
4386:      *
4387:      * @return    string $locale Locale to use for the translation, e.g. 'fr_FR'
4388:      */
4389:     public function getLocale()
4390:     {
4391:         return $this->currentLocale;
4392:     }
4393: 
4394:     /**
4395:      * Returns the current translation for a given locale
4396:      *
4397:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
4398:      * @param     PropelPDO $con an optional connection object
4399:      *
4400:      * @return CategoryI18n */
4401:     public function getTranslation($locale = 'en_US', PropelPDO $con = null)
4402:     {
4403:         if (!isset($this->currentTranslations[$locale])) {
4404:             if (null !== $this->collCategoryI18ns) {
4405:                 foreach ($this->collCategoryI18ns as $translation) {
4406:                     if ($translation->getLocale() == $locale) {
4407:                         $this->currentTranslations[$locale] = $translation;
4408: 
4409:                         return $translation;
4410:                     }
4411:                 }
4412:             }
4413:             if ($this->isNew()) {
4414:                 $translation = new CategoryI18n();
4415:                 $translation->setLocale($locale);
4416:             } else {
4417:                 $translation = CategoryI18nQuery::create()
4418:                     ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
4419:                     ->findOneOrCreate($con);
4420:                 $this->currentTranslations[$locale] = $translation;
4421:             }
4422:             $this->addCategoryI18n($translation);
4423:         }
4424: 
4425:         return $this->currentTranslations[$locale];
4426:     }
4427: 
4428:     /**
4429:      * Remove the translation for a given locale
4430:      *
4431:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
4432:      * @param     PropelPDO $con an optional connection object
4433:      *
4434:      * @return    Category The current object (for fluent API support)
4435:      */
4436:     public function removeTranslation($locale = 'en_US', PropelPDO $con = null)
4437:     {
4438:         if (!$this->isNew()) {
4439:             CategoryI18nQuery::create()
4440:                 ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
4441:                 ->delete($con);
4442:         }
4443:         if (isset($this->currentTranslations[$locale])) {
4444:             unset($this->currentTranslations[$locale]);
4445:         }
4446:         foreach ($this->collCategoryI18ns as $key => $translation) {
4447:             if ($translation->getLocale() == $locale) {
4448:                 unset($this->collCategoryI18ns[$key]);
4449:                 break;
4450:             }
4451:         }
4452: 
4453:         return $this;
4454:     }
4455: 
4456:     /**
4457:      * Returns the current translation
4458:      *
4459:      * @param     PropelPDO $con an optional connection object
4460:      *
4461:      * @return CategoryI18n */
4462:     public function getCurrentTranslation(PropelPDO $con = null)
4463:     {
4464:         return $this->getTranslation($this->getLocale(), $con);
4465:     }
4466: 
4467: 
4468:         /**
4469:          * Get the [title] column value.
4470:          *
4471:          * @return string
4472:          */
4473:         public function getTitle()
4474:         {
4475:         return $this->getCurrentTranslation()->getTitle();
4476:     }
4477: 
4478: 
4479:         /**
4480:          * Set the value of [title] column.
4481:          *
4482:          * @param string $v new value
4483:          * @return CategoryI18n The current object (for fluent API support)
4484:          */
4485:         public function setTitle($v)
4486:         {    $this->getCurrentTranslation()->setTitle($v);
4487: 
4488:         return $this;
4489:     }
4490: 
4491: 
4492:         /**
4493:          * Get the [description] column value.
4494:          *
4495:          * @return string
4496:          */
4497:         public function getDescription()
4498:         {
4499:         return $this->getCurrentTranslation()->getDescription();
4500:     }
4501: 
4502: 
4503:         /**
4504:          * Set the value of [description] column.
4505:          *
4506:          * @param string $v new value
4507:          * @return CategoryI18n The current object (for fluent API support)
4508:          */
4509:         public function setDescription($v)
4510:         {    $this->getCurrentTranslation()->setDescription($v);
4511: 
4512:         return $this;
4513:     }
4514: 
4515: 
4516:         /**
4517:          * Get the [chapo] column value.
4518:          *
4519:          * @return string
4520:          */
4521:         public function getChapo()
4522:         {
4523:         return $this->getCurrentTranslation()->getChapo();
4524:     }
4525: 
4526: 
4527:         /**
4528:          * Set the value of [chapo] column.
4529:          *
4530:          * @param string $v new value
4531:          * @return CategoryI18n The current object (for fluent API support)
4532:          */
4533:         public function setChapo($v)
4534:         {    $this->getCurrentTranslation()->setChapo($v);
4535: 
4536:         return $this;
4537:     }
4538: 
4539: 
4540:         /**
4541:          * Get the [postscriptum] column value.
4542:          *
4543:          * @return string
4544:          */
4545:         public function getPostscriptum()
4546:         {
4547:         return $this->getCurrentTranslation()->getPostscriptum();
4548:     }
4549: 
4550: 
4551:         /**
4552:          * Set the value of [postscriptum] column.
4553:          *
4554:          * @param string $v new value
4555:          * @return CategoryI18n The current object (for fluent API support)
4556:          */
4557:         public function setPostscriptum($v)
4558:         {    $this->getCurrentTranslation()->setPostscriptum($v);
4559: 
4560:         return $this;
4561:     }
4562: 
4563:     // versionable behavior
4564: 
4565:     /**
4566:      * Enforce a new Version of this object upon next save.
4567:      *
4568:      * @return Category
4569:      */
4570:     public function enforceVersioning()
4571:     {
4572:         $this->enforceVersion = true;
4573: 
4574:         return $this;
4575:     }
4576: 
4577:     /**
4578:      * Checks whether the current state must be recorded as a version
4579:      *
4580:      * @param PropelPDO $con An optional PropelPDO connection to use.
4581:      *
4582:      * @return  boolean
4583:      */
4584:     public function isVersioningNecessary($con = null)
4585:     {
4586:         if ($this->alreadyInSave) {
4587:             return false;
4588:         }
4589: 
4590:         if ($this->enforceVersion) {
4591:             return true;
4592:         }
4593: 
4594:         if (CategoryPeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) {
4595:             return true;
4596:         }
4597: 
4598:         return false;
4599:     }
4600: 
4601:     /**
4602:      * Creates a version of the current object and saves it.
4603:      *
4604:      * @param   PropelPDO $con the connection to use
4605:      *
4606:      * @return  CategoryVersion A version object
4607:      */
4608:     public function addVersion($con = null)
4609:     {
4610:         $this->enforceVersion = false;
4611: 
4612:         $version = new CategoryVersion();
4613:         $version->setId($this->getId());
4614:         $version->setParent($this->getParent());
4615:         $version->setLink($this->getLink());
4616:         $version->setVisible($this->getVisible());
4617:         $version->setPosition($this->getPosition());
4618:         $version->setCreatedAt($this->getCreatedAt());
4619:         $version->setUpdatedAt($this->getUpdatedAt());
4620:         $version->setVersion($this->getVersion());
4621:         $version->setVersionCreatedAt($this->getVersionCreatedAt());
4622:         $version->setVersionCreatedBy($this->getVersionCreatedBy());
4623:         $version->setCategory($this);
4624:         $version->save($con);
4625: 
4626:         return $version;
4627:     }
4628: 
4629:     /**
4630:      * Sets the properties of the curent object to the value they had at a specific version
4631:      *
4632:      * @param   integer $versionNumber The version number to read
4633:      * @param   PropelPDO $con the connection to use
4634:      *
4635:      * @return  Category The current object (for fluent API support)
4636:      * @throws  PropelException - if no object with the given version can be found.
4637:      */
4638:     public function toVersion($versionNumber, $con = null)
4639:     {
4640:         $version = $this->getOneVersion($versionNumber, $con);
4641:         if (!$version) {
4642:             throw new PropelException(sprintf('No Category object found with version %d', $version));
4643:         }
4644:         $this->populateFromVersion($version, $con);
4645: 
4646:         return $this;
4647:     }
4648: 
4649:     /**
4650:      * Sets the properties of the curent object to the value they had at a specific version
4651:      *
4652:      * @param   CategoryVersion $version The version object to use
4653:      * @param   PropelPDO $con the connection to use
4654:      * @param   array $loadedObjects objects thats been loaded in a chain of populateFromVersion calls on referrer or fk objects.
4655:      *
4656:      * @return  Category The current object (for fluent API support)
4657:      */
4658:     public function populateFromVersion($version, $con = null, &$loadedObjects = array())
4659:     {
4660: 
4661:         $loadedObjects['Category'][$version->getId()][$version->getVersion()] = $this;
4662:         $this->setId($version->getId());
4663:         $this->setParent($version->getParent());
4664:         $this->setLink($version->getLink());
4665:         $this->setVisible($version->getVisible());
4666:         $this->setPosition($version->getPosition());
4667:         $this->setCreatedAt($version->getCreatedAt());
4668:         $this->setUpdatedAt($version->getUpdatedAt());
4669:         $this->setVersion($version->getVersion());
4670:         $this->setVersionCreatedAt($version->getVersionCreatedAt());
4671:         $this->setVersionCreatedBy($version->getVersionCreatedBy());
4672: 
4673:         return $this;
4674:     }
4675: 
4676:     /**
4677:      * Gets the latest persisted version number for the current object
4678:      *
4679:      * @param   PropelPDO $con the connection to use
4680:      *
4681:      * @return  integer
4682:      */
4683:     public function getLastVersionNumber($con = null)
4684:     {
4685:         $v = CategoryVersionQuery::create()
4686:             ->filterByCategory($this)
4687:             ->orderByVersion('desc')
4688:             ->findOne($con);
4689:         if (!$v) {
4690:             return 0;
4691:         }
4692: 
4693:         return $v->getVersion();
4694:     }
4695: 
4696:     /**
4697:      * Checks whether the current object is the latest one
4698:      *
4699:      * @param   PropelPDO $con the connection to use
4700:      *
4701:      * @return  boolean
4702:      */
4703:     public function isLastVersion($con = null)
4704:     {
4705:         return $this->getLastVersionNumber($con) == $this->getVersion();
4706:     }
4707: 
4708:     /**
4709:      * Retrieves a version object for this entity and a version number
4710:      *
4711:      * @param   integer $versionNumber The version number to read
4712:      * @param   PropelPDO $con the connection to use
4713:      *
4714:      * @return  CategoryVersion A version object
4715:      */
4716:     public function getOneVersion($versionNumber, $con = null)
4717:     {
4718:         return CategoryVersionQuery::create()
4719:             ->filterByCategory($this)
4720:             ->filterByVersion($versionNumber)
4721:             ->findOne($con);
4722:     }
4723: 
4724:     /**
4725:      * Gets all the versions of this object, in incremental order
4726:      *
4727:      * @param   PropelPDO $con the connection to use
4728:      *
4729:      * @return  PropelObjectCollection A list of CategoryVersion objects
4730:      */
4731:     public function getAllVersions($con = null)
4732:     {
4733:         $criteria = new Criteria();
4734:         $criteria->addAscendingOrderByColumn(CategoryVersionPeer::VERSION);
4735: 
4736:         return $this->getCategoryVersions($criteria, $con);
4737:     }
4738: 
4739:     /**
4740:      * Compares the current object with another of its version.
4741:      * <code>
4742:      * print_r($book->compareVersion(1));
4743:      * => array(
4744:      *   '1' => array('Title' => 'Book title at version 1'),
4745:      *   '2' => array('Title' => 'Book title at version 2')
4746:      * );
4747:      * </code>
4748:      *
4749:      * @param   integer   $versionNumber
4750:      * @param   string    $keys Main key used for the result diff (versions|columns)
4751:      * @param   PropelPDO $con the connection to use
4752:      * @param   array     $ignoredColumns  The columns to exclude from the diff.
4753:      *
4754:      * @return  array A list of differences
4755:      */
4756:     public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
4757:     {
4758:         $fromVersion = $this->toArray();
4759:         $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
4760: 
4761:         return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
4762:     }
4763: 
4764:     /**
4765:      * Compares two versions of the current object.
4766:      * <code>
4767:      * print_r($book->compareVersions(1, 2));
4768:      * => array(
4769:      *   '1' => array('Title' => 'Book title at version 1'),
4770:      *   '2' => array('Title' => 'Book title at version 2')
4771:      * );
4772:      * </code>
4773:      *
4774:      * @param   integer   $fromVersionNumber
4775:      * @param   integer   $toVersionNumber
4776:      * @param   string    $keys Main key used for the result diff (versions|columns)
4777:      * @param   PropelPDO $con the connection to use
4778:      * @param   array     $ignoredColumns  The columns to exclude from the diff.
4779:      *
4780:      * @return  array A list of differences
4781:      */
4782:     public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
4783:     {
4784:         $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
4785:         $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
4786: 
4787:         return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
4788:     }
4789: 
4790:     /**
4791:      * Computes the diff between two versions.
4792:      * <code>
4793:      * print_r($this->computeDiff(1, 2));
4794:      * => array(
4795:      *   '1' => array('Title' => 'Book title at version 1'),
4796:      *   '2' => array('Title' => 'Book title at version 2')
4797:      * );
4798:      * </code>
4799:      *
4800:      * @param   array     $fromVersion     An array representing the original version.
4801:      * @param   array     $toVersion       An array representing the destination version.
4802:      * @param   string    $keys            Main key used for the result diff (versions|columns).
4803:      * @param   array     $ignoredColumns  The columns to exclude from the diff.
4804:      *
4805:      * @return  array A list of differences
4806:      */
4807:     protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
4808:     {
4809:         $fromVersionNumber = $fromVersion['Version'];
4810:         $toVersionNumber = $toVersion['Version'];
4811:         $ignoredColumns = array_merge(array(
4812:             'Version',
4813:             'VersionCreatedAt',
4814:             'VersionCreatedBy',
4815:         ), $ignoredColumns);
4816:         $diff = array();
4817:         foreach ($fromVersion as $key => $value) {
4818:             if (in_array($key, $ignoredColumns)) {
4819:                 continue;
4820:             }
4821:             if ($toVersion[$key] != $value) {
4822:                 switch ($keys) {
4823:                     case 'versions':
4824:                         $diff[$fromVersionNumber][$key] = $value;
4825:                         $diff[$toVersionNumber][$key] = $toVersion[$key];
4826:                         break;
4827:                     default:
4828:                         $diff[$key] = array(
4829:                             $fromVersionNumber => $value,
4830:                             $toVersionNumber => $toVersion[$key],
4831:                         );
4832:                         break;
4833:                 }
4834:             }
4835:         }
4836: 
4837:         return $diff;
4838:     }
4839:     /**
4840:      * retrieve the last $number versions.
4841:      *
4842:      * @param integer $number the number of record to return.
4843:      * @param CategoryVersionQuery|Criteria $criteria Additional criteria to filter.
4844:      * @param PropelPDO $con An optional connection to use.
4845:      *
4846:      * @return PropelCollection|CategoryVersion[] List of CategoryVersion objects
4847:      */
4848:     public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null)
4849:     {
4850:         $criteria = CategoryVersionQuery::create(null, $criteria);
4851:         $criteria->addDescendingOrderByColumn(CategoryVersionPeer::VERSION);
4852:         $criteria->limit($number);
4853: 
4854:         return $this->getCategoryVersions($criteria, $con);
4855:     }
4856: }
4857: 
thelia API documentation generated by ApiGen 2.8.0