@@ -1134,9 +1134,9 @@ protected function parseGetParameterArray($get,$name,$characters) {
1134
1134
return $ values ;
1135
1135
}
1136
1136
1137
- protected function applyBeforeHandler (&$ action ,&$ database ,&$ table ,&$ id ,&$ callback ,&$ inputs ) {
1137
+ protected function applyBeforeHandler (&$ action ,&$ database ,&$ table ,&$ id ,&$ callback ,&$ input ) {
1138
1138
if (is_callable ($ callback ,true )) {
1139
- $ callback ($ action ,$ database ,$ table ,$ id ,$ inputs );
1139
+ $ callback ($ action ,$ database ,$ table ,$ id ,$ input );
1140
1140
}
1141
1141
}
1142
1142
@@ -1862,19 +1862,6 @@ protected function getParameters($settings) {
1862
1862
$ page = $ this ->processPageParameter ($ page );
1863
1863
$ orderings = $ this ->processOrderingsParameter ($ orderings );
1864
1864
1865
- // input
1866
- $ multi = (strpos ($ key [0 ],', ' )!==false ) || (strlen ($ post )?($ post [0 ]=='[ ' ):false );
1867
- $ inputs = $ this ->retrieveInputs ($ post );
1868
- if ($ before ) {
1869
- if ($ action == 'delete ' && $ multi ) {
1870
- $ inputs = array ();
1871
- for ($ i =1 ; $ i <= count (explode (', ' , $ key [0 ])); $ i ++) {
1872
- $ inputs [] = (object ) array ();
1873
- }
1874
- }
1875
- $ this ->applyBeforeHandler ($ action ,$ database ,$ tables [0 ],$ key [0 ],$ before ,$ inputs );
1876
- }
1877
-
1878
1865
// reflection
1879
1866
list ($ tables ,$ collect ,$ select ) = $ this ->findRelations ($ tables ,$ database ,$ auto_include );
1880
1867
$ fields = $ this ->findFields ($ tables ,$ columns ,$ exclude ,$ select ,$ database );
@@ -1886,17 +1873,34 @@ protected function getParameters($settings) {
1886
1873
if ($ tenancy_function ) $ this ->applyTenancyFunction ($ tenancy_function ,$ action ,$ database ,$ fields ,$ filters );
1887
1874
if ($ column_authorizer ) $ this ->applyColumnAuthorizer ($ column_authorizer ,$ action ,$ database ,$ fields );
1888
1875
1876
+ // input
1877
+ $ multi = (strpos ($ key [0 ],', ' )!==false ) || (strlen ($ post )?($ post [0 ]=='[ ' ):false );
1878
+ if ($ before && $ action == 'delete ' && $ multi ) {
1879
+ $ inputs = array ();
1880
+ for ($ i =1 ; $ i <= count (explode (', ' , $ key [0 ])); $ i ++) {
1881
+ $ inputs [] = (object ) array ();
1882
+ }
1883
+ } else {
1884
+ $ inputs = $ this ->retrieveInputs ($ post );
1885
+ }
1886
+ $ originalAction = $ action ;
1889
1887
foreach ($ inputs as $ k =>$ context ) {
1888
+ //echo $k.' - ';
1890
1889
$ input = $ this ->filterInputByFields ($ context ,$ fields [$ tables [0 ]]);
1891
1890
1892
1891
if ($ tenancy_function ) $ this ->applyInputTenancy ($ tenancy_function ,$ action ,$ database ,$ tables [0 ],$ input ,$ fields [$ tables [0 ]]);
1893
1892
if ($ input_sanitizer ) $ this ->applyInputSanitizer ($ input_sanitizer ,$ action ,$ database ,$ tables [0 ],$ input ,$ fields [$ tables [0 ]]);
1894
1893
if ($ input_validator ) $ this ->applyInputValidator ($ input_validator ,$ action ,$ database ,$ tables [0 ],$ input ,$ fields [$ tables [0 ]],$ context );
1895
1894
1896
- $ this ->convertInputs ($ input ,$ fields [$ tables [0 ]]);
1895
+ $ this ->convertInputs ($ input ,$ fields [$ tables [0 ]]);
1896
+
1897
+ if ($ before ) {
1898
+ $ action = $ originalAction ;
1899
+ $ this ->applyBeforeHandler ($ action ,$ database ,$ tables [0 ],$ ids [$ k ],$ before ,$ input );
1900
+ }
1901
+
1897
1902
$ inputs [$ k ] = $ input ;
1898
1903
}
1899
-
1900
1904
return compact ('action ' ,'database ' ,'tables ' ,'key ' ,'page ' ,'filters ' ,'fields ' ,'orderings ' ,'transform ' ,'multi ' ,'inputs ' ,'collect ' ,'select ' ,'before ' ,'after ' );
1901
1905
}
1902
1906
0 commit comments