These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Yajra\DataTables\Html; |
||
4 | |||
5 | use Yajra\DataTables\Html\Editor\Editor; |
||
6 | |||
7 | trait HasEditor |
||
8 | { |
||
9 | /** |
||
10 | * Collection of Editors. |
||
11 | * |
||
12 | * @var null|Editor |
||
13 | */ |
||
14 | protected $editors = []; |
||
15 | |||
16 | /** |
||
17 | * Attach multiple editors to builder. |
||
18 | * |
||
19 | * @param mixed ...$editors |
||
20 | * @return $this |
||
21 | * @see https://editor.datatables.net/ |
||
22 | * @throws \Exception |
||
23 | */ |
||
24 | public function editors(...$editors) |
||
25 | { |
||
26 | foreach ($editors as $editor) { |
||
27 | $this->editor($editor); |
||
28 | } |
||
29 | |||
30 | return $this; |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Integrate with DataTables Editor. |
||
35 | * |
||
36 | * @param array|Editor $fields |
||
37 | * @return $this |
||
38 | * @see https://editor.datatables.net/ |
||
39 | * @throws \Exception |
||
40 | */ |
||
41 | public function editor($fields) |
||
42 | { |
||
43 | $this->setTemplate($this->config->get('datatables-html.editor', 'datatables::editor')); |
||
44 | |||
45 | $editor = $this->newEditor($fields); |
||
46 | |||
47 | $this->editors[] = $editor; |
||
48 | |||
49 | return $this; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @param array|Editor $fields |
||
54 | * @return array|Editor |
||
55 | * @throws \Exception |
||
56 | */ |
||
57 | protected function newEditor($fields) |
||
58 | { |
||
59 | if ($fields instanceof Editor) { |
||
60 | $editor = $fields; |
||
61 | } else { |
||
62 | $editor = new Editor; |
||
63 | $editor->fields($fields); |
||
64 | } |
||
65 | |||
66 | if (! $editor->table) { |
||
0 ignored issues
–
show
|
|||
67 | $editor->table($this->getTableAttribute('id')); |
||
68 | } |
||
69 | |||
70 | if (! $editor->ajax) { |
||
0 ignored issues
–
show
The property
ajax does not exist on object<Yajra\DataTables\Html\Editor\Editor> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
71 | $editor->ajax($this->getAjaxUrl()); |
||
72 | } |
||
73 | |||
74 | return $editor; |
||
75 | } |
||
76 | } |
||
77 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.