1 | <?php |
||
20 | abstract class AbstractField implements FieldPropsInterface |
||
21 | { |
||
22 | use Hidden; |
||
23 | use Width; |
||
24 | use Column; |
||
25 | use Tab; |
||
26 | use Readonly; |
||
27 | use DefaultTrait; |
||
28 | use Title; |
||
29 | use Name; |
||
30 | use OldAndAttribute; |
||
31 | use Model; |
||
32 | use Filter; |
||
33 | |||
34 | const DEFAULT_TAB_IDENT = '[extra]'; |
||
35 | |||
36 | private $crud; |
||
37 | public static $repeaterAdapterClass; |
||
38 | |||
39 | 1002 | public static function make($name = '', $title = '') |
|
40 | { |
||
41 | 1002 | $field = new static; |
|
42 | |||
43 | 1002 | if (!$title) { |
|
44 | 951 | $title = preg_replace('~_~', ' ', ucfirst($name)); |
|
45 | } |
||
46 | 1002 | $field->title($title); |
|
47 | 1002 | $field->name($name); |
|
48 | 1002 | $field->tab(self::DEFAULT_TAB_IDENT); |
|
49 | |||
50 | 1002 | return $field; |
|
51 | } |
||
52 | |||
53 | 19 | public function value(Request $request) |
|
54 | { |
||
55 | 19 | $value = $request->get($this->name()); |
|
56 | 19 | if (!$value && $this->isNullable()) { |
|
57 | 3 | return null; |
|
58 | } |
||
59 | |||
60 | 19 | return $value; |
|
61 | } |
||
62 | |||
63 | 14 | public function shouldSkip(Request $request) |
|
64 | { |
||
65 | 14 | return false; |
|
66 | } |
||
67 | |||
68 | 1 | public function afterStore($model, Request $request) |
|
72 | |||
73 | 2 | public function afterUpdate($model, Request $request) |
|
77 | |||
78 | 1 | public function beforeUpdate($model) |
|
79 | { |
||
80 | // dummy |
||
82 | |||
83 | 12 | public function isInline() |
|
87 | |||
88 | 19 | public function isRelationField() |
|
92 | |||
93 | 16 | public function isMultiple() |
|
97 | |||
98 | 17 | public function isEncode() |
|
102 | |||
103 | 74 | public function isMarkupRow() |
|
107 | |||
108 | 4 | public function isOrderable() |
|
112 | |||
113 | 17 | public function isAjax() |
|
117 | |||
118 | 3 | public function isNullable() |
|
122 | |||
123 | 13 | public function hasTooltip() |
|
127 | |||
128 | 14 | public function hasClipboardButton() |
|
132 | |||
133 | 70 | public function isTranslatable() |
|
137 | |||
138 | 16 | public function isMaskable() |
|
142 | |||
143 | 8 | public function getPlaceholder() |
|
147 | |||
148 | 15 | public function hasMaxlength(): bool |
|
152 | |||
153 | 1 | public function getHistoryView($value) |
|
159 | |||
160 | abstract public function getListView($model); |
||
161 | |||
162 | abstract public function getEditFormView($model); |
||
163 | |||
164 | abstract public function getCreateFormView(); |
||
165 | |||
166 | // TODO: interface type-hinting |
||
167 | 58 | public function prepare(CRUD $crud) |
|
190 | |||
191 | protected function crud(): CRUD |
||
195 | } |
||
196 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: