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
964124
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();
	}
261262
protected function newModelQuery($model = null)
    {
        return is_null($model)
                ? $this->createModel()->newQuery()
                : $model->newQuery();
    }
828946
public function generate($model)
    {
        $generator = new Generator(
            $this->setting->getModelDirectory(),
            $model
        );

        if ($generator->fileExists()) {
            echo Color::red('The model already exists.');

            exit(1);
        }

        $generator->write('model/model', [
            'baseNamespace' => $this->namespaces['model']
        ]);

        echo Color::green("The model was well created.");
    }
1338617
public static function createFromModel(Model $model)
    {
        $table = $model->getTable();

        $dc = new static($table);

        $dc->strTable = $model->getTable();
        $dc->activeRecord = $model;
        $dc->intId = $model->id;

        return $dc;
    }
1050242
public function persist(AbstractModel $model)
    {
        $collection = $this->getCollectionBy(
            $this->getModelConfiguration(get_class($model))
        );

        $this->setLastResult(
            $collection->insert($this->getModelDataAsArray($model))
        );

        return (bool) ($this->lastResult) ? $this->lastResult[self::RESULT_OK_INDEX] : false;
    }
945173
public function update(Model $model) {

		return $this->_populate(
			$this->_request('put', $this->_getUrl('element', $model->getPrimaryKey()), [
				'json' => $model->getAttributes()
			]),
			false
		);
	}
409185
public function save(Model $model)
    {
        $foreignKey = $this->getForeignKeyName();
        $parentKeyValue = $this->getParentKey();

        if (is_array($foreignKey)) { //Check for multi-columns relationship
            foreach ($foreignKey as $index => $key) {
                $model->setAttribute($key, $parentKeyValue[$index]);
            }
        } else {
            $model->setAttribute($foreignKey, $parentKeyValue);
        }

        return $model->save() ? $model : false;
    }
1081700
public function setModel($model)
	{
		$this->model = $model;
		
		$this->from($this->model->metableTable() . ' AS m');
		
		if ($this->model->metableTableSoftDeletes()) {
			$this->whereNull('m.' . $this->model->getDeletedAtColumn());
		}
		
		return $this;
	}
776019
public function saveAs($model)
    {
        if (is_string($model)) {
            $model = $this->app->normalizeClassName($model, 'Model');
            $model = $this->add($model);
        }
        $this->_save_as = $model;
        $res = $this->save();
        $this->_save_as = null;

        return $res;
    }
134562
public function setModel($model)
    {
        // convert the model class into an instance
        if (!is_object($model)) {
            $this->modelClass = $model;
            $model = new $model($this->modelId);
        } else {
            $this->modelId = $model->ids();
            $this->modelClass = get_class($model);
        }

        $this->model = $model;

        return $this;
    }
359988
public function afterDelete(Model $Model) {
		if ($this->settings[$Model->alias]['auto'] === false) {
			return;
		}
		if (!$Model->ShadowModel) {
			return;
		}
		if (isset($this->deleteUpdates[$Model->alias]) && !empty($this->deleteUpdates[$Model->alias])) {
			foreach ($this->deleteUpdates[$Model->alias] as $assocAlias => $assocIds) {
				$Model->{$assocAlias}->updateRevisions($assocIds);
			}
			unset($this->deleteUpdates[$Model->alias]);
		}
	}
833890
public function save(NavigationModel $model)
    {
        $record = NavigationRecord::findOne(['id' => $model->id]);

        if (!$record) {
            $record = new NavigationRecord();
        }

        $model->validate();

        if ($model->hasErrors()) {
            return false;
        }

        $record->layoutId = $model->layoutId;
        $record->handle = $model->handle;
        $record->currLabel = $model->currLabel;
        $record->prevLabel = $model->prevLabel;
        $record->enabled = $model->enabled;
        $record->order = $model->order;
        $record->url = $model->url;
        $record->prevUrl = $model->prevUrl;
        $record->icon = $model->icon;
        $record->customIcon = $model->customIcon;
        $record->manualNav = $model->manualNav;
        $record->newWindow = $model->newWindow;
        $record->validate();

        if ($record->hasErrors()) {
            $model->addErrors($record->getErrors());

            return false;
        }

        if (!$record->save()) {
            return false;
        }

        if (!$model->id) {
            $model->id = $record->id;
        }

        return $model;
    }
751005
public function saving(Model $model)
    {
        if ( ! $model->getRuleset('creating') && ! $model->getRuleset('updating')) {
            return $this->performValidation($model, 'saving');
        }
    }
295978
public function previous(Model $Model, $options = array()) {
		if (!$Model->id) {
			trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
			return array();
		}
		if (!$Model->ShadowModel) {
			trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
			return array();
		}
		$options['limit'] = 1;
		$options['page'] = 2;
		if (isset($options['conditions'])) {
			$options['conditions'] = array_merge($options['conditions'], array($Model->primaryKey => $Model->id));
		} else {
			$options['conditions'] = array($Model->primaryKey => $Model->id);
		}
		$revisions = $Model->ShadowModel->find('all', $options);
		if (!$revisions) {
			return array();
		}
		return $revisions[0];
	}
789625
public function saveEntity(Model $model)
    {
        $cacheKey = $this->cacheKey($model->toArray());
        $this->cache->forget($cacheKey);
        return $model->save();
    }
475045
public function setModel(Model $model)
    {
        $this->model = $model;

        $this->query->from($model->getTable());

        return $this;
    }
1061806
public function create(Model $model) {

		return $this->_populate(
			$this->_request('post', $this->_getUrl('collection'), [
				'json' => $model->getAttributes()
			]),
			false
		);
	}