Passed
Push — master ( cc7747...d2190f )
by Mihail
10:36
created

FormContentRestore::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Apps\Model\Admin\Content;
4
5
use Apps\ActiveRecord\Content;
6
use Ffcms\Core\Arch\Model;
7
use Ffcms\Core\Helper\Serialize;
8
9
/**
10
 * Class FormContentRestore. Restore deleted content item from active record trash state
11
 * @package Apps\Model\Admin\Content
12
 */
13
class FormContentRestore extends Model
14
{
15
    public $id;
16
    public $title;
17
18
    private $_record;
19
20
    /**
21
     * FormContentRestore constructor. Pass active record object inside
22
     * @param Content $record
23
     */
24
    public function __construct(Content $record)
25
    {
26
        $this->_record = $record;
27
        parent::__construct();
28
    }
29
30
    /**
31
     * Set public attributes from active record object
32
     */
33
    public function before()
34
    {
35
        $this->id = $this->_record->id;
36
        $this->title = Serialize::getDecodeLocale($this->_record->title);
37
    }
38
39
    /**
40
     * Form display labels
41
     * @return array
42
     */
43
    public function labels()
44
    {
45
        return [
46
            'title' => __('Title')
47
        ];
48
    }
49
50
    /**
51
     * Make restore of trashed item
52
     */
53
    public function make()
54
    {
55
        $this->_record->restore();
56
    }
57
}