Adds class phpdoc comment and opening of class.

@param string &$script The script will be modified in this method.
334376
protected function addClassOpen(&$script)
    {
        $tableName = $this->getTable()->getName();
        $tableDesc = $this->getTable()->getDescription();

        if ($this->getBuildProperty('addClassLevelComment')) {
            $script .= "
/**
 * Base static class for performing query and update operations on the '$tableName' table.
 *
 * $tableDesc
 *";
            if ($this->getBuildProperty('addTimeStamp')) {
                $now = strftime('%c');
                $script .= "
 * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:
 *
 * $now
 *";
            }

            $script .= "
 * @package propel.generator." . $this->getPackage() . "
 */";
        }

        $extendingPeerClass = '';
        $parentClass = $this->getBehaviorContent('parentClass');
        if (null !== $parentClass) {
            $extendingPeerClass = ' extends ' . $parentClass;
        }

        $script .= "
abstract class " . $this->getClassname() . $extendingPeerClass . "
{
";
    }
115091
protected function addHookMethods(&$script)
    {
        $hooks = [];
        foreach (['pre', 'post'] as $hook) {
            foreach (['Insert', 'Update', 'Save', 'Delete'] as $action) {
                $hooks[$hook.$action] = false === strpos($script, "function $hook.$action(");
            }
        }
        $script .= $this->renderTemplate('baseObjectMethodHook', $hooks);
    }
374460
protected function addClear(&$script)
    {
        $table = $this->getTable();

        $script .= "
    /**
     * Clears the current object and sets all attributes to their default values
     */
    public function clear()
    {";
        foreach ($table->getColumns() as $col) {
            $clo = strtolower($col->getName());
            $script .= "
        \$this->" . $clo . " = null;";
            if ($col->isLazyLoad()) {
                $script .= "
        \$this->" . $clo . "_isLoaded = false;";
            }
            if ($col->getType() == PropelTypes::OBJECT || $col->getType() == PropelTypes::PHP_ARRAY) {
                $cloUnserialized = $clo . '_unserialized';
                $script .= "
        \$this->$cloUnserialized = null;";
            }
        }

        $script .= "
        \$this->alreadyInSave = false;
        \$this->alreadyInValidation = false;
        \$this->alreadyInClearAllReferencesDeep = false;
        \$this->clearAllReferences();";

        if ($this->hasDefaultValues()) {
            $script .= "
        \$this->applyDefaultValues();";
        }

        $script .= "
        \$this->resetModified();
        \$this->setNew(true);
        \$this->setDeleted(false);
    }
";
    }
316603
protected function addConstructorBody(&$script)
    {
        $table = $this->getTable();
        $script .= "
        if (null === \$dbName) {
            \$dbName = '" . $table->getDatabase()->getName() . "';
        }
        if (null === \$modelName) {
            \$modelName = '" . addslashes($this->getNewStubObjectBuilder($table)->getFullyQualifiedClassname()) . "';
        }
        parent::__construct(\$dbName, \$modelName, \$modelAlias);";
    }
723142
protected function addDoSelectJoinAllExcept(&$script)
    {
        $table = $this->getTable();
        $join_behavior = $this->getJoinBehavior();

        // ------------------------------------------------------------------------
        // doSelectJoinAllExcept*()
        // ------------------------------------------------------------------------

        // 2) create a bunch of doSelectJoinAllExcept*() methods
        // -- these were existing in original Torque, so we should keep them for compatibility

        $fkeys = $table->getForeignKeys(); // this sep assignment is necessary otherwise sub-loops over
        // getForeignKeys() will cause this to only execute one time.
        foreach ($fkeys as $fk) {

            $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());

            $excludedTable = $table->getDatabase()->getTable($fk->getForeignTableName());

            $thisTableObjectBuilder = $this->getNewObjectBuilder($table);
            $excludedTableObjectBuilder = $this->getNewObjectBuilder($excludedTable);
            $excludedTablePeerBuilder = $this->getNewPeerBuilder($excludedTable);

            $excludedClassName = $excludedTableObjectBuilder->getObjectClassname();


            $script .= "

    /**
     * Selects a collection of " . $this->getObjectClassname() . " objects pre-filled with all related objects except " . $thisTableObjectBuilder->getFKPhpNameAffix($fk) . ".
     *
     * @param      Criteria  \$criteria
     * @param      PropelPDO \$con
     * @param      String    \$join_behavior the type of joins to use, defaults to $join_behavior
     * @return array           Array of " . $this->getObjectClassname() . " objects.
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function doSelectJoinAllExcept" . $thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false) . "(Criteria \$criteria, \$con = null, \$join_behavior = $join_behavior)
    {
        \$criteria = clone \$criteria;

        // Set the correct dbName if it has not been overridden
        // \$criteria->getDbName() will return the same object if not set to another value
        // so == check is okay and faster
        if (\$criteria->getDbName() == Propel::getDefaultDB()) {
            \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME);
        }

        " . $this->getPeerClassname() . "::addSelectColumns(\$criteria);
        \$startcol2 = " . $this->getPeerClassname() . "::NUM_HYDRATE_COLUMNS;
";
            $index = 2;
            foreach ($table->getForeignKeys() as $subfk) {
                // want to cover this case, but the code is not there yet.
                // Why not? - because we would have to alias the tables in the join
                if (!($subfk->getForeignTableName() == $table->getName())) {
                    $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName());
                    $joinTablePeerBuilder = $this->getNewPeerBuilder($joinTable);
                    $joinClassName = $joinTablePeerBuilder->getObjectClassname();

                    if ($joinClassName != $excludedClassName) {
                        $new_index = $index + 1;
                        $script .= "
        " . $joinTablePeerBuilder->getPeerClassname() . "::addSelectColumns(\$criteria);
        \$startcol$new_index = \$startcol$index + " . $joinTablePeerBuilder->getPeerClassname() . "::NUM_HYDRATE_COLUMNS;
";
                        $index = $new_index;
                    } // if joinClassName not excludeClassName
                } // if subfk is not curr table
            } // foreach [sub] foreign keys

            foreach ($table->getForeignKeys() as $subfk) {
                // want to cover this case, but the code is not there yet.
                if ($subfk->getForeignTableName() != $table->getName()) {
                    $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName());
                    $joinedTablePeerBuilder = $this->getNewPeerBuilder($joinTable);
                    $joinClassName = $joinedTablePeerBuilder->getObjectClassname();

                    if ($joinClassName != $excludedClassName) {
                        $script .= $this->addCriteriaJoin($subfk, $table, $joinTable, $joinedTablePeerBuilder);
                    }
                }
            } // foreach fkeys

            // apply behaviors
            $this->applyBehaviorModifier('preSelect', $script);

            $script .= "

        \$stmt = " . $this->basePeerClassname . "::doSelect(\$criteria, \$con);
        \$results = array();

        while (\$row = \$stmt->fetch(PDO::FETCH_NUM)) {
            \$key1 = " . $this->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, 0);
            if (null !== (\$obj1 = " . $this->getPeerClassname() . "::getInstanceFromPool(\$key1))) {
                // We no longer rehydrate the object, since this can cause data loss.
                // See http://www.propelorm.org/ticket/509
                // \$obj1->hydrate(\$row, 0, true); // rehydrate
            } else {";
            if ($table->getChildrenColumn()) {
                $script .= "
                \$omClass = " . $this->getPeerClassname() . "::getOMClass(\$row, 0);
                \$cls = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1);
";
            } else {
                $script .= "
                \$cls = " . $this->getPeerClassname() . "::getOMClass();
";
            }

            $script .= "
                " . $this->buildObjectInstanceCreationCode('$obj1', '$cls') . "
                \$obj1->hydrate(\$row);
                " . $this->getPeerClassname() . "::addInstanceToPool(\$obj1, \$key1);
            } // if obj1 already loaded
";

            $index = 1;
            foreach ($table->getForeignKeys() as $subfk) {
                // want to cover this case, but the code is not there yet.
                if ($subfk->getForeignTableName() != $table->getName()) {

                    $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName());

                    $joinedTableObjectBuilder = $this->getNewObjectBuilder($joinTable);
                    $joinedTablePeerBuilder = $this->getNewPeerBuilder($joinTable);

                    $joinClassName = $joinedTableObjectBuilder->getObjectClassname();

                    $interfaceName = $joinClassName;
                    if ($joinTable->getInterface()) {
                        $interfaceName = $this->prefixClassname($joinTable->getInterface());
                    }

                    if ($joinClassName != $excludedClassName) {

                        $index++;

                        $script .= "
                // Add objects for joined $joinClassName rows

                \$key$index = " . $joinedTablePeerBuilder->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, \$startcol$index);
                if (\$key$index !== null) {
                    \$obj$index = " . $joinedTablePeerBuilder->getPeerClassname() . "::getInstanceFromPool(\$key$index);
                    if (!\$obj$index) {
    ";

                        if ($joinTable->getChildrenColumn()) {
                            $script .= "
                        \$omClass = " . $joinedTablePeerBuilder->getPeerClassname() . "::getOMClass(\$row, \$startcol$index);
            \$cls = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1);
";
                        } else {
                            $script .= "
                        \$cls = " . $joinedTablePeerBuilder->getPeerClassname() . "::getOMClass();
";
                        } /* $joinTable->getChildrenColumn() */
                        $script .= "
                    " . $this->buildObjectInstanceCreationCode('$obj' . $index, '$cls') . "
                    \$obj" . $index . "->hydrate(\$row, \$startcol$index);
                    " . $joinedTablePeerBuilder->getPeerClassname() . "::addInstanceToPool(\$obj$index, \$key$index);
                } // if \$obj$index already loaded

                // Add the \$obj1 (" . $this->getObjectClassname() . ") to the collection in \$obj" . $index . " (" . $joinedTablePeerBuilder->getObjectClassname() . ")";
                        if ($subfk->isLocalPrimaryKey()) {
                            $script .= "
                \$obj1->set" . $joinedTablePeerBuilder->getObjectClassname() . "(\$obj" . $index . ");";
                        } else {
                            $script .= "
                \$obj" . $index . "->add" . $joinedTableObjectBuilder->getRefFKPhpNameAffix($subfk, $plural = false) . "(\$obj1);";
                        }
                        $script .= "

            } // if joined row is not null
";
                    } // if ($joinClassName != $excludedClassName) {
                } // $subfk->getForeignTableName() != $table->getName()
            } // foreach
            $script .= "
            \$results[] = \$obj1;
        }
        \$stmt->closeCursor();

        return \$results;
    }
";
        } // foreach fk

    }
440741
protected function addGetOMClass_Inheritance(&$script)
    {
        $col = $this->getTable()->getChildrenColumn();
        $script .= "
    /**
     * The returned Class will contain objects of the default type or
     * objects that inherit from the default.
     *
     * @param array   \$row ConnectionInterface result row.
     * @param int     \$colnum Column to examine for OM class information (first is 0).
     * @param boolean \$withPrefix Whether or not to return the path with the class name
     * @throws PropelException Any exceptions caught during processing will be
     *                         rethrown wrapped into a PropelException.
     *
     * @return string The OM class
     */
    public static function getOMClass(\$row, \$colnum, \$withPrefix = true)
    {
        try {
";
        if ($col->isEnumeratedClasses()) {
            $script .= "
            \$omClass = null;
            \$classKey = \$row[\$colnum + " . ($col->getPosition() - 1) . "];

            switch (\$classKey) {
";
            foreach ($col->getChildren() as $child) {
                $script .= "
                case {$this->getTableMapClassName()}::CLASSKEY_".$child->getConstantSuffix().":
                    \$omClass = {$this->getTableMapClassName()}::CLASSNAME_".$child->getConstantSuffix().";
                    break;
";
            } /* foreach */
            $script .= "
                default:
                    \$omClass = {$this->getTableMapClassName()}::CLASS_DEFAULT;
";
            $script .= "
            } // switch
            if (!\$withPrefix) {
                \$omClass = preg_replace('#\.#', '\\\\', \$omClass);
            }
";
        } else { /* if not enumerated */
            $script .= "
            \$omClass = \$row[\$colnum + ".($col->getPosition()-1)."];
            \$omClass = preg_replace('#\.#', '\\\\', '.'.\$omClass);
";
        }
        $script .= "
        } catch (\Exception \$e) {
            throw new PropelException('Unable to get OM class.', \$e);
        }

        return \$omClass;
    }
";
    }
758182
protected function addClassOpen(&$script)
    {
        $table = $this->getTable();
        $tableName = $table->getName();
        $tableDesc = $table->getDescription();

        $baseBuilder = $this->getNewQueryInheritanceBuilder($this->getChild());
        $baseClassName = $this->getClassNameFromBuilder($baseBuilder);

        if ($this->getBuildProperty('generator.objectModel.addClassLevelComment')) {
            $script .= "

/**
 * Skeleton subclass for representing a query for one of the subclasses of the '$tableName' table.
 *
 * $tableDesc
 *";
            if ($this->getBuildProperty('generator.objectModel.addTimeStamp')) {
                $now = strftime('%c');
                $script .= "
 * This class was autogenerated by Propel " . $this->getBuildProperty('general.version') . " on:
 *
 * $now
 *";
            }
            $script .= "
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 */";
        }
        $script .= "
class "  .$this->getUnqualifiedClassName() . " extends " . $baseClassName . "
{
";
    }
282725
protected function addGetPeer(&$script)
    {
        $this->addGetPeerComment($script);
        $this->addGetPeerFunctionOpen($script);
        $this->addGetPeerFunctionBody($script);
        $this->addGetPeerFunctionClose($script);
    }
219169
protected function addClassOpen(&$script)
    {
        $table = $this->getTable();
        $tableName = $table->getName();
        $tableDesc = $table->getDescription();

        $baseBuilder = $this->getStubQueryBuilder();
        $this->declareClassFromBuilder($baseBuilder);
        $baseClassName = $this->getParentClassName();

        $script .= "
/**
 * Skeleton subclass for representing a query for one of the subclasses of the '$tableName' table.
 *
 * $tableDesc
 *";
        if ($this->getBuildProperty('generator.objectModel.addTimeStamp')) {
            $now = strftime('%c');
            $script .= "
 * This class was autogenerated by Propel " . $this->getBuildProperty('general.version') . " on:
 *
 * $now
 *";
        }
        $script .= "
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 */
class "  .$this->getUnqualifiedClassName() . " extends " . $baseClassName . "
{
";
    }
1359753
protected function addApplyDefaultValues(&$script)
    {
        $this->addApplyDefaultValuesComment($script);
        $this->addApplyDefaultValuesOpen($script);
        $this->addApplyDefaultValuesBody($script);
        $this->addApplyDefaultValuesClose($script);
    }
211952
protected function addMutatorOpen(&$script, Column $col)
    {
        $this->addMutatorComment($script, $col);
        $this->addMutatorOpenOpen($script, $col);
        $this->addMutatorOpenBody($script, $col);
    }
448745
protected function addClassBody(&$script)
    {
        $this->declareClassFromBuilder($this->getStubObjectBuilder());
        $this->declareClassFromBuilder($this->getStubQueryBuilder());
        $this->declareClassFromBuilder($this->getTableMapBuilder());

        $this->declareClasses(
            '\Exception',
            '\PDO',
            '\Propel\Runtime\Exception\PropelException',
            '\Propel\Runtime\Connection\ConnectionInterface',
            '\Propel\Runtime\Collection\Collection',
            '\Propel\Runtime\Collection\ObjectCollection',
            '\Propel\Runtime\Collection\ObjectCombinationCollection',
            '\Propel\Runtime\Exception\BadMethodCallException',
            '\Propel\Runtime\Exception\PropelException',
            '\Propel\Runtime\ActiveQuery\Criteria',
            '\Propel\Runtime\ActiveQuery\ModelCriteria',
            '\Propel\Runtime\ActiveRecord\ActiveRecordInterface',
            '\Propel\Runtime\Parser\AbstractParser',
            '\Propel\Runtime\Propel',
            '\Propel\Runtime\Map\TableMap'
        );

        $baseClass = $this->getBaseClass();
        if (strrpos($baseClass, '\\') !== false) {
            $this->declareClasses($baseClass);
        }

        $table = $this->getTable();
        if (!$table->isAlias()) {
            $this->addConstants($script);
            $this->addAttributes($script);
        }

        if ($table->hasCrossForeignKeys()) {
            /* @var $refFK ForeignKey */
            foreach ($table->getCrossFks() as $crossFKs) {
                $this->addCrossScheduledForDeletionAttribute($script, $crossFKs);
            }
        }

        foreach ($table->getReferrers() as $refFK) {
            if (!$refFK->isLocalPrimaryKey()) {
                $this->addRefFkScheduledForDeletionAttribute($script, $refFK);
            }
        }

        if ($this->hasDefaultValues()) {
            $this->addApplyDefaultValues($script);
        }
        $this->addConstructor($script);

        $this->addBaseObjectMethods($script);

        $this->addColumnAccessorMethods($script);
        $this->addColumnMutatorMethods($script);

        $this->addHasOnlyDefaultValues($script);

        $this->addHydrate($script);
        $this->addEnsureConsistency($script);

        if (!$table->isReadOnly()) {
            $this->addManipulationMethods($script);
        }

        if ($this->isAddGenericAccessors()) {
            $this->addGetByName($script);
            $this->addGetByPosition($script);
            $this->addToArray($script);
        }

        if ($this->isAddGenericMutators()) {
            $this->addSetByName($script);
            $this->addSetByPosition($script);
            $this->addFromArray($script);
            $this->addImportFrom($script);
        }

        $this->addBuildCriteria($script);
        $this->addBuildPkeyCriteria($script);
        $this->addHashCode($script);
        $this->addGetPrimaryKey($script);
        $this->addSetPrimaryKey($script);
        $this->addIsPrimaryKeyNull($script);

        $this->addCopy($script);

        $this->addFKMethods($script);
        $this->addRefFKMethods($script);
        $this->addCrossFKMethods($script);
        $this->addClear($script);
        $this->addClearAllReferences($script);

        $this->addPrimaryString($script);

        // apply behaviors
        $this->applyBehaviorModifier('objectMethods', $script, "    ");

        if ($this->getBuildProperty('generator.objectModel.addHooks')) {
            $this->addHookMethods($script);
        }

        $this->addMagicCall($script);
    }
859491
protected function addUpdateMethods(&$script)
    {
        $this->addDoInsert($script);
        $this->addDoUpdate($script);
        $this->addDoDeleteAll($script);
        $this->addDoDelete($script);
        if ($this->isDeleteCascadeEmulationNeeded()) {
            $this->addDoOnDeleteCascade($script);
        }
        if ($this->isDeleteSetNullEmulationNeeded()) {
            $this->addDoOnDeleteSetNull($script);
        }
        $this->addDoValidate($script);
    }
1311826
protected function addGetOMClass_Inheritance(&$script)
    {
        $col = $this->getTable()->getChildrenColumn();
        $script .= "
    /**
     * The returned Class will contain objects of the default type or
     * objects that inherit from the default.
     *
     * @param      array \$row PropelPDO result row.
     * @param      int \$colnum Column to examine for OM class information (first is 0).
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function getOMClass(\$row = 0, \$colnum = 0)
    {
        try {
";
        if ($col->isEnumeratedClasses()) {
            $script .= "
            \$omClass = null;
            \$classKey = \$row[\$colnum + " . ($col->getPosition() - 1) . "];

            switch (\$classKey) {
";
            foreach ($col->getChildren() as $child) {
                $script .= "
                case " . $this->getPeerClassname() . "::CLASSKEY_" . strtoupper($child->getKey()) . ":
                    \$omClass = " . $this->getPeerClassname() . "::CLASSNAME_" . strtoupper($child->getKey()) . ";
                    break;
";
            } /* foreach */
            $script .= "
                default:
                    \$omClass = " . $this->getPeerClassname() . "::OM_CLASS;
";
            $script .= "
            } // switch
";
        } else { /* if not enumerated */
            $script .= "
            \$omClass = \$row[\$colnum + " . ($col->getPosition() - 1) . "];
            \$omClass = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1);
";
        }
        $script .= "
        } catch (Exception \$e) {
            throw new PropelException('Unable to get OM class.', \$e);
        }

        return \$omClass;
    }
";
    }
1268507
protected function addValidationMethods(&$script)
    {
        $this->addValidationFailuresAttribute($script);
        $this->addGetValidationFailures($script);
        $this->addValidate($script);
        $this->addDoValidate($script);
    }
915429
protected function addCopy(&$script)
    {
        $this->addCopyInto($script);

        $script .= "
    /**
     * Makes a copy of this object that will be inserted as a new row in table when saved.
     * It creates a new object filling in the simple attributes, but skipping any primary
     * keys that are defined for the table.
     *
     * If desired, this method can also make copies of all associated (fkey referrers)
     * objects.
     *
     * @param  boolean \$deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
     * @return ".$this->getObjectClassName(true)." Clone of current object.
     * @throws PropelException
     */
    public function copy(\$deepCopy = false)
    {
        // we use get_class(), because this might be a subclass
        \$clazz = get_class(\$this);
        " . $this->buildObjectInstanceCreationCode('$copyObj', '$clazz') . "
        \$this->copyInto(\$copyObj, \$deepCopy);

        return \$copyObj;
    }
";
    }
203407
protected function addSaveOpen(&$script)
    {
        $table = $this->getTable();
        $reloadOnUpdate = $table->isReloadOnUpdate();
        $reloadOnInsert = $table->isReloadOnInsert();
        $script .= "
    public function save(ConnectionInterface \$con = null".($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload = false" : "").")
    {";
    }