Jarves\Propel\Behavior\WorkspaceBehavior::addDoBackupRecord PHP Method

addDoBackupRecord() protected method

protected addDoBackupRecord ( &$script )
    protected function addDoBackupRecord(&$script)
    {
        $table = $this->getTable();
        $versionTable = '\\' . $this->versionTablePhpName;
        if ($table->getNamespace()) {
            $versionTable = '\\' . $table->getNamespace() . $versionTable;
        }
        $script .= '
    /**
    * @param Criteria            $criteria
    * @Param ConnectionInterface $con
    */
    public static function doBackupRecord(Criteria $criteria, ConnectionInterface $con = null)
    {
        $items = static::create(null, $criteria)->find($con);

        foreach ($items as $item) {
            $version = new ' . $versionTable . ';
';
        foreach ($this->table->getColumns() as $col) {
            $script .= "\n            \$version->set" . $col->getPhpName() . "(\$item->get" . $col->getPhpName() . "());";
        }
        $script .= '
            $version->save($con);
        }
    }
';
    }