Completed
Push — master ( 062b68...81f5ad )
by Terzi
08:48
created

Textarea::markdown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Terranet\Administrator\Field;
4
5
use Terranet\Administrator\Scaffolding;
6
7
class Textarea extends Generic
8
{
9
    const EDITOR_TINYMCE = 'tinymce';
10
    const EDITOR_CKEDITOR = 'ckeditor';
11
    const EDITOR_MEDIUM = 'medium';
12
    const EDITOR_MARKDOWN = 'markdown';
13
14
    /** @var array */
15
    protected $visibility = [
16
        Scaffolding::PAGE_INDEX => false,
17
        Scaffolding::PAGE_EDIT => true,
18
        Scaffolding::PAGE_VIEW => true,
19
    ];
20
21
    protected $editor = false;
22
23
    /**
24
     * @param $editor
25
     * @return bool
26
     */
27
    public function editorEnabled($editor)
28
    {
29
        return $editor === $this->editor;
30
    }
31
32
    /**
33
     * @return $this
34
     */
35
    public function tinymce()
36
    {
37
        $this->editor = static::EDITOR_TINYMCE;
38
39
        return $this;
40
    }
41
42
    /**
43
     * @return $this
44
     */
45
    public function ckeditor()
46
    {
47
        $this->editor = static::EDITOR_CKEDITOR;
48
49
        return $this;
50
    }
51
52
    /**
53
     * @return $this
54
     */
55
    public function medium()
56
    {
57
        $this->editor = static::EDITOR_MEDIUM;
58
59
        return $this;
60
    }
61
62
    /**
63
     * @return $this
64
     */
65
    public function markdown()
66
    {
67
        $this->editor = static::EDITOR_MARKDOWN;
68
69
        return $this;
70
    }
71
72
    /**
73
     * @return array
74
     */
75
    public function onEdit()
76
    {
77
        return $this->editor ? [
78
            'dataEditor' => $this->editor,
79
        ] : [];
80
    }
81
}
82