You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

41 lines
809 B

<?php
/**
* Created by Error202
* Date: 27.07.2018
*/
namespace common\modules\pages\helpers;
use common\modules\pages\entities\Page;
use core\entities\Meta;
class PageHelper
{
public static function saveRevision(Page $model) {
if (!$model->revision_id) {
$model->revision_at = time();
$page = Page::create(
$model->title,
$model->slug,
$model->content,
Page::TYPE_REVISION,
new Meta(
$model->meta->title,
$model->meta->description,
$model->meta->keywords
)
);
$page->revision_at = $model->updated_at;
$page->revision_id = $model->id;
//$page->type = Page::TYPE_REVISION;
//$page->tree = 2;
$parent = Page::find()->andWhere(['slug' => 'temp'])->andWhere(['depth' => 0])->one();
$page->appendTo($parent);
$page->save();
}
}
}