Model/Behavior/RevisionBehavior.php
public function createRevision(Model $Model) {
		if (!$Model->id) {
			trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
			return false;
		}
		if (!$Model->ShadowModel) {
			trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
			return false;
		}
		$habtm = array();
		$allHabtm = $Model->getAssociated('hasAndBelongsToMany');
		foreach ($allHabtm as $assocAlias) {
			if (isset($Model->ShadowModel->_schema[$assocAlias])) {
				$habtm[] = $assocAlias;
			}
		}
		$data = $Model->find('first', array(
				'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id),
				'contain' => $habtm));
		$Model->ShadowModel->create($data);
		$Model->ShadowModel->set('version_created', date('Y-m-d H:i:s'));
		foreach ($habtm as $assocAlias) {
			$foreignKeys = Hash::extract($data, '{n}.' . $assocAlias . '.' . $Model->{$assocAlias}->primaryKey);
			$Model->ShadowModel->set($assocAlias, implode(',', $foreignKeys));
		}
		return (bool)$Model->ShadowModel->save();
	}
public function createRevision(Model $Model) {
		if (!$Model->id) {
			trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
			return false;
		}
		if (!$Model->ShadowModel) {
			trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
			return false;
		}
		$habtm = array();
		$allHabtm = $Model->getAssociated('hasAndBelongsToMany');
		foreach ($allHabtm as $assocAlias) {
			if (isset($Model->ShadowModel->_schema[$assocAlias])) {
				$habtm[] = $assocAlias;
			}
		}
		$data = $Model->find('first', array(
				'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id),
				'contain' => $habtm));
		$Model->ShadowModel->create($data);
		$Model->ShadowModel->set('version_created', date('Y-m-d H:i:s'));
		foreach ($habtm as $assocAlias) {
			$foreignKeys = Hash::extract($data, '{n}.' . $assocAlias . '.' . $Model->{$assocAlias}->primaryKey);
			$Model->ShadowModel->set($assocAlias, implode(',', $foreignKeys));
		}
		return (bool)$Model->ShadowModel->save();
	}
public function createRevision ( Model $ Model ) { if ( ! $ Model -> id ) { trigger_error ( 'RevisionBehavior: Model::id must be set' , E_USER_WARNING ) ; return false ; } if ( ! $ Model -> ShadowModel ) { trigger_error ( 'RevisionBehavior: ShadowModel doesnt exist.' , E_USER_WARNING ) ; return false ; } $ habtm = array ( ) ; $ allHabtm = $ Model -> getAssociated ( 'hasAndBelongsToMany' ) ; foreach ( $ allHabtm as $ assocAlias ) { if ( isset ( $ Model -> ShadowModel -> _schema [ $ assocAlias ] ) ) { $ habtm [ ] = $ assocAlias ; } } $ data = $ Model -> find ( 'first' , array ( 'conditions' => array ( $ Model -> alias . '.' . $ Model -> primaryKey => $ Model -> id ) , 'contain' => $ habtm ) ) ; $ Model -> ShadowModel -> create ( $ data ) ; $ Model -> ShadowModel -> set ( 'version_created' , date ( 'Y-m-d H:i:s' ) ) ; foreach ( $ habtm as $ assocAlias ) { $ foreignKeys = Hash :: extract ( $ data , '{n}.' . $ assocAlias . '.' . $ Model -> { $ assocAlias } -> primaryKey ) ; $ Model -> ShadowModel -> set ( $ assocAlias , implode ( ',' , $ foreignKeys ) ) ; } return ( bool ) $ Model -> ShadowModel -> save ( ) ; }
Manually create a revision of the current record of Model->id

@example $this->Post->id = 5; $this->Post->createRevision();
@param object $Model
@return bool Success
Manually create a revision of the current record of Model - > id