# File core/lib/Thelia/Model/om/BaseCategory.php | thelia

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