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