Completed
Pull Request — master (#1350)
by
unknown
03:01
created

Editor::dir()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Form\Field;
4
5
use Encore\Admin\Form\Field;
6
7
class Editor extends Field
8
{
9
    protected static $js = [
10
        '//cdn.ckeditor.com/4.5.10/standard/ckeditor.js',
11
    ];
12
13
    public function __construct($column, array $arguments = [])
14
    {
15
        parent::__construct($column, $arguments);
16
17
        $this->options(['contentsLangDirection' => 'ltr']);
18
        $this->options(['language' => config('app.locale', 'en')]);
19
20
    }
21
22
    /**
23
     * set `direction` .
24
     * https://docs-old.ckeditor.com/ckeditor_api/symbols/CKEDITOR.config.html#.contentsLangDirection
25
     * 'ui' – indicates that content direction will be the same as the user interface language direction;
26
     * 'ltr' – for Left-To-Right language (like English);
27
     * 'rtl' – for Right-To-Left languages (like Arabic).
28
     * @param string $dir
29
     * @return $this
30
     */
31
    public function dir($dir)
32
    {
33
        return $this->options(['contentsLangDirection' => $dir]);
34
    }
35
36
    /**
37
     * set language for editor
38
     * @param string $dir
39
     * @return $this
40
     */
41
    public function lang($dir)
42
    {
43
        return $this->options(['language' => $dir]);
44
    }
45
46 View Code Duplication
    public function render()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47
    {
48
        $options = json_encode($this->options);
49
        $this->script = "CKEDITOR.replace('{$this->column}', $options);";
50
51
        return parent::render();
0 ignored issues
show
Bug Compatibility introduced by
The expression parent::render(); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 51 which is incompatible with the return type declared by the interface Illuminate\Contracts\Support\Renderable::render of type string.
Loading history...
52
    }
53
}
54