21 parent::__construct($name, $arguments, $controller,
$data,
$scope);
33 if(in_array(self::TO_SNAKE, $this->format))
35 $arguments = $this->convertToSnakeCase($arguments);
38 if(in_array(self::CHECK_REQUIRED, $this->format))
40 $check = $this->check($arguments);
41 if(!$check->isSuccess())
43 $r->addErrors($check->getErrors());
49 if(in_array(self::TO_WHITE_LIST, $this->format))
51 $arguments = $this->internalize($arguments);
56 return $r->setData([
'data'=>$r->isSuccess()?$arguments:
null]);
59 protected function convertToSnakeCase($arguments=[])
68 if(isset($arguments[
'select']))
70 $fields = $arguments[
'select'];
72 $arguments[
'select'] = $entity->convertKeysToSnakeCaseSelect($fields);
75 if(isset($arguments[
'filter']))
77 $fields = $arguments[
'filter'];
79 $arguments[
'filter'] = $entity->convertKeysToSnakeCaseFilter($fields);
82 if(isset($arguments[
'order']))
84 $fields = $arguments[
'order'];
86 $arguments[
'order'] = $entity->convertKeysToSnakeCaseOrder($fields);
89 elseif ($name ==
'getfields'){}
90 elseif ($name ==
'get'){}
91 elseif ($name ==
'delete'){}
92 elseif ($name ==
'modify'
96 || $name ==
'tryupdate'
97 || $name ==
'trymodify')
99 if(isset($arguments[
'fields']))
101 $fields = $arguments[
'fields'];
103 $arguments[
'fields'] = $entity->convertKeysToSnakeCaseFields($fields);
108 $arguments = $entity->convertKeysToSnakeCaseArguments($name, $arguments);
114 private function internalize($arguments)
123 $fields = $arguments[
'fields'];
125 $arguments[
'fields'] = $entity->internalizeFieldsAdd($fields);
127 elseif ($name ==
'update')
129 $fields = $arguments[
'fields'];
131 $arguments[
'fields'] = $entity->internalizeFieldsUpdate($fields);
133 elseif ($name ==
'list')
135 $fields = $entity->internalizeFieldsList([
136 'select'=>$arguments[
'select'],
137 'filter'=>$arguments[
'filter'],
138 'order'=>$arguments[
'order'],
141 $fields = $entity->rewriteFieldsList([
142 'select'=>$fields[
'select'],
143 'filter'=>$fields[
'filter'],
144 'order'=>$fields[
'order'],
147 $arguments[
'select'] = $fields[
'select'];
148 $arguments[
'filter'] = $fields[
'filter'];
149 $arguments[
'order'] = $fields[
'order'];
151 elseif ($name ==
'getfields'){}
152 elseif ($name ==
'get'){}
153 elseif ($name ==
'delete'){}
154 elseif ($name ==
'modify')
156 $fields = $arguments[
'fields'];
158 $arguments[
'fields'] = $entity->internalizeFieldsModify($fields);
160 elseif ($name ==
'tryadd')
162 $fields = $arguments[
'fields'];
164 $arguments[
'fields'] = $entity->internalizeFieldsTryAdd($fields);
166 elseif ($name ==
'tryupdate')
168 $fields = $arguments[
'fields'];
170 $arguments[
'fields'] = $entity->internalizeFieldsUpdate($fields);
172 elseif ($name ==
'trymodify')
174 $fields = $arguments[
'fields'];
176 $arguments[
'fields'] = $entity->internalizeFieldsTryModify($fields);
180 $arguments = $entity->internalizeArguments($name, $arguments);
186 protected function check($arguments)
197 $r = $entity->checkFieldsAdd($arguments[
'fields']);
199 elseif ($name ==
'update')
201 $r = $entity->checkFieldsUpdate($arguments[
'fields']);
203 elseif ($name ==
'list'){}
204 elseif ($name ==
'getfields'){}
205 elseif ($name ==
'get'){}
206 elseif ($name ==
'delete'){}
207 elseif ($name ==
'modify')
209 $r = $entity->checkFieldsModify($arguments[
'fields']);
211 elseif ($name ==
'tryadd')
213 $r = $entity->checkFieldsAdd($arguments[
'fields']);
215 elseif ($name ==
'tryupdate')
217 $r = $entity->checkFieldsUpdate($arguments[
'fields']);
219 elseif ($name ==
'trymodify')
221 $r = $entity->checkFieldsModify($arguments[
'fields']);
225 $r = $entity->checkArguments($name, $arguments);