1 | <?php |
||
7 | class Editor extends Fluent |
||
8 | { |
||
9 | use HasEvents; |
||
10 | |||
11 | const DISPLAY_LIGHTBOX = 'lightbox'; |
||
12 | const DISPLAY_ENVELOPE = 'envelope'; |
||
13 | const DISPLAY_BOOTSTRAP = 'bootstrap'; |
||
14 | const DISPLAY_FOUNDATION = 'foundation'; |
||
15 | const DISPLAY_JQUERYUI = 'jqueryui'; |
||
16 | |||
17 | /** |
||
18 | * Editor constructor. |
||
19 | * |
||
20 | * @param string $instance |
||
21 | */ |
||
22 | public function __construct($instance = 'editor') |
||
28 | |||
29 | /** |
||
30 | * Make new Editor instance. |
||
31 | * |
||
32 | * @param string $instance |
||
33 | * @return Editor |
||
34 | */ |
||
35 | public static function make($instance = 'editor') |
||
39 | |||
40 | /** |
||
41 | * Append raw scripts. |
||
42 | * |
||
43 | * @param string $scripts |
||
44 | * @return Editor |
||
45 | */ |
||
46 | public function scripts($scripts) |
||
52 | |||
53 | /** |
||
54 | * Set Editor's variable name / instance. |
||
55 | * |
||
56 | * @param $instance |
||
57 | * @return $this |
||
58 | */ |
||
59 | public function instance($instance) |
||
65 | |||
66 | /** |
||
67 | * Set Editor's ajax parameter. |
||
68 | * |
||
69 | * @param string|array $ajax |
||
70 | * @return $this |
||
71 | * @see https://editor.datatables.net/reference/option/ajax |
||
72 | */ |
||
73 | public function ajax($ajax) |
||
79 | |||
80 | /** |
||
81 | * Set Editor's table source. |
||
82 | * |
||
83 | * @param string $table |
||
84 | * @return $this |
||
85 | * @see https://editor.datatables.net/reference/option/table |
||
86 | */ |
||
87 | public function table($table) |
||
93 | |||
94 | /** |
||
95 | * Set Editor's idSrc option. |
||
96 | * |
||
97 | * @param string $idSrc |
||
98 | * @return $this |
||
99 | * @see https://editor.datatables.net/reference/option/idSrc |
||
100 | */ |
||
101 | public function idSrc($idSrc = 'DT_RowId') |
||
107 | |||
108 | /** |
||
109 | * Set Editor's display option. |
||
110 | * |
||
111 | * @param string $display |
||
112 | * @return $this |
||
113 | * @see https://editor.datatables.net/reference/option/display |
||
114 | */ |
||
115 | public function display($display) |
||
121 | |||
122 | /** |
||
123 | * Set Editor's fields. |
||
124 | * |
||
125 | * @param array $fields |
||
126 | * @return $this |
||
127 | * @see https://editor.datatables.net/reference/option/fields |
||
128 | */ |
||
129 | public function fields(array $fields) |
||
135 | |||
136 | /** |
||
137 | * Set Editor's language. |
||
138 | * |
||
139 | * @param array $language |
||
140 | * @return $this |
||
141 | * @see https://editor.datatables.net/reference/option/i18n |
||
142 | */ |
||
143 | public function language(array $language) |
||
149 | |||
150 | /** |
||
151 | * Set Editor's template. |
||
152 | * |
||
153 | * @param string $template |
||
154 | * @return $this |
||
155 | * @see https://editor.datatables.net/reference/option/template |
||
156 | */ |
||
157 | public function template($template) |
||
163 | } |
||
164 |
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.