1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Terranet\Administrator\Form\Collection; |
4
|
|
|
|
5
|
|
|
use Terranet\Administrator\Collection\Mutable as BaseMutableCollection; |
6
|
|
|
use Terranet\Administrator\Columns\MediaElement; |
|
|
|
|
7
|
|
|
use Terranet\Administrator\Exception; |
8
|
|
|
use Terranet\Administrator\Field\Textarea; |
9
|
|
|
use Terranet\Administrator\Form\FormElement; |
|
|
|
|
10
|
|
|
use Terranet\Administrator\Form\FormSection; |
|
|
|
|
11
|
|
|
use Terranet\Administrator\Form\InputFactory; |
|
|
|
|
12
|
|
|
|
13
|
|
|
class Mutable extends BaseMutableCollection |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Whether the collection has active editor of specific type. |
17
|
|
|
* |
18
|
|
|
* @param $editor |
19
|
|
|
* |
20
|
|
|
* @throws Exception |
21
|
|
|
* |
22
|
|
|
* @return bool |
23
|
|
|
*/ |
24
|
|
|
public function hasEditors($editor) |
25
|
|
|
{ |
26
|
|
|
$this->validateEditor($editor); |
27
|
|
|
|
28
|
|
|
return (bool) $this->filter(function ($field) use ($editor) { |
29
|
|
|
return $field instanceof Textarea && $field->editorEnabled($editor); |
30
|
|
|
})->count(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Set rich editors. |
35
|
|
|
* |
36
|
|
|
* @param mixed string|array $fields |
37
|
|
|
*/ |
38
|
|
|
public function editors($fields, string $editor = null) |
39
|
|
|
{ |
40
|
|
|
if (is_array($fields)) { |
41
|
|
|
foreach ($fields as $field => $editor) { |
42
|
|
|
$this->editors($field, $editor); |
43
|
|
|
} |
44
|
|
|
} elseif (is_string($fields) && $editor) { |
45
|
|
|
$item = $this->find($fields); |
46
|
|
|
if ($item instanceof Textarea) { |
47
|
|
|
if (method_exists($item, $editor)) { |
48
|
|
|
$item->$editor(); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
return $this; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Set fields descriptions. |
58
|
|
|
* |
59
|
|
|
* @param mixed string|array $fields |
60
|
|
|
*/ |
61
|
|
|
public function hints($fields, string $hint = null) |
62
|
|
|
{ |
63
|
|
|
if (is_array($fields)) { |
64
|
|
|
foreach ($fields as $field => $hint) { |
65
|
|
|
$this->hints($field, $hint); |
66
|
|
|
} |
67
|
|
|
} elseif (is_string($fields) && $hint) { |
68
|
|
|
$item = $this->find($fields); |
69
|
|
|
$item->setDescription($hint); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param $editor |
77
|
|
|
* |
78
|
|
|
* @throws Exception |
79
|
|
|
*/ |
80
|
|
|
protected function validateEditor($editor) |
81
|
|
|
{ |
82
|
|
|
if (!in_array($editor, ['ckeditor', 'tinymce', 'medium', 'markdown'], true)) { |
83
|
|
|
throw new Exception(sprintf('Unknown editor %s', $editor)); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths