Maurits van der Schee 6 years ago
parent
commit
4c925dcc81

+ 7
- 7
README.md View File

@@ -149,7 +149,7 @@ You can enable the following middleware using the "middlewares" config parameter
149 149
 - "validation": Return input validation errors for custom rules
150 150
 - "sanitation": Apply input sanitation on create and update
151 151
 - "multiTenancy": Restricts tenants access in a multi-tenant scenario
152
-- "custom": Provides handlers for request and response customization
152
+- "customization": Provides handlers for request and response customization
153 153
 
154 154
 The "middlewares" config parameter is a comma separated list of enabled middlewares.
155 155
 You can tune the middleware behavior using middleware specific configuration parameters:
@@ -171,8 +171,8 @@ You can tune the middleware behavior using middleware specific configuration par
171 171
 - "validation.handler": Handler to implement validation rules for input values ("")
172 172
 - "sanitation.handler": Handler to implement sanitation rules for input values ("")
173 173
 - "multiTenancy.handler": Handler to implement simple multi-tenancy rules ("")
174
-- "custom.beforeHandler": Handler to implement request customization ("")
175
-- "custom.afterHandler": Handler to implement response customization ("")
174
+- "customization.beforeHandler": Handler to implement request customization ("")
175
+- "customization.afterHandler": Handler to implement response customization ("")
176 176
 
177 177
 If you don't specify these parameters in the configuration, then the default values (between brackets) are used.
178 178
 
@@ -698,14 +698,14 @@ If your tenants are identified by the "customer_id" column you can use the follo
698 698
 This construct adds a filter requiring "customer_id" to be "12" to every operation (except for "create").
699 699
 It also sets the column "customer_id" on "create" to "12" and removes the column from any other write operation.
700 700
 
701
-### Custom handlers
701
+### Customization handlers
702 702
 
703
-You may use the "custom" middleware to implement any other functionality.
703
+You may use the "customization" middleware to implement any other functionality.
704 704
 
705
-    'custom.beforeHandler' => function ($operation, $tableName, $request, $environment) {
705
+    'customization.beforeHandler' => function ($operation, $tableName, $request, $environment) {
706 706
         $environment->start = microtime(true);
707 707
     },
708
-    'custom.afterHandler' => function ($operation, $tableName, $response, $environment) {
708
+    'customization.afterHandler' => function ($operation, $tableName, $response, $environment) {
709 709
         $response->addHeader('X-Time-Taken', microtime(true) - $environment->start);
710 710
     },
711 711
 

+ 3
- 3
api.php View File

@@ -3037,9 +3037,9 @@ class CorsMiddleware extends Middleware
3037 3037
     }
3038 3038
 }
3039 3039
 
3040
-// file: src/Tqdev/PhpCrudApi/Middleware/CustomMiddleware.php
3040
+// file: src/Tqdev/PhpCrudApi/Middleware/CustomizationMiddleware.php
3041 3041
 
3042
-class CustomMiddleware extends Middleware
3042
+class CustomizationMiddleware extends Middleware
3043 3043
 {
3044 3044
     private $reflection;
3045 3045
 
@@ -4828,7 +4828,7 @@ class Api
4828 4828
                     new AuthorizationMiddleware($router, $responder, $properties, $reflection);
4829 4829
                     break;
4830 4830
                 case 'custom':
4831
-                    new CustomMiddleware($router, $responder, $properties, $reflection);
4831
+                    new CustomizationMiddleware($router, $responder, $properties, $reflection);
4832 4832
                     break;
4833 4833
             }
4834 4834
         }

+ 3
- 3
src/Tqdev/PhpCrudApi/Api.php View File

@@ -13,7 +13,7 @@ use Tqdev\PhpCrudApi\Database\GenericDB;
13 13
 use Tqdev\PhpCrudApi\Middleware\AuthorizationMiddleware;
14 14
 use Tqdev\PhpCrudApi\Middleware\BasicAuthMiddleware;
15 15
 use Tqdev\PhpCrudApi\Middleware\CorsMiddleware;
16
-use Tqdev\PhpCrudApi\Middleware\CustomMiddleware;
16
+use Tqdev\PhpCrudApi\Middleware\CustomizationMiddleware;
17 17
 use Tqdev\PhpCrudApi\Middleware\FirewallMiddleware;
18 18
 use Tqdev\PhpCrudApi\Middleware\JwtAuthMiddleware;
19 19
 use Tqdev\PhpCrudApi\Middleware\MultiTenancyMiddleware;
@@ -70,8 +70,8 @@ class Api
70 70
                 case 'authorization':
71 71
                     new AuthorizationMiddleware($router, $responder, $properties, $reflection);
72 72
                     break;
73
-                case 'custom':
74
-                    new CustomMiddleware($router, $responder, $properties, $reflection);
73
+                case 'customization':
74
+                    new CustomizationMiddleware($router, $responder, $properties, $reflection);
75 75
                     break;
76 76
             }
77 77
         }

src/Tqdev/PhpCrudApi/Middleware/CustomMiddleware.php → src/Tqdev/PhpCrudApi/Middleware/CustomizationMiddleware.php View File

@@ -9,7 +9,7 @@ use Tqdev\PhpCrudApi\Record\RequestUtils;
9 9
 use Tqdev\PhpCrudApi\Request;
10 10
 use Tqdev\PhpCrudApi\Response;
11 11
 
12
-class CustomMiddleware extends Middleware
12
+class CustomizationMiddleware extends Middleware
13 13
 {
14 14
     private $reflection;
15 15
 

+ 3
- 3
tests/config/base.php View File

@@ -4,7 +4,7 @@ $settings = [
4 4
     'username' => 'php-crud-api',
5 5
     'password' => 'php-crud-api',
6 6
     'controllers' => 'records,columns,cache,openapi',
7
-    'middlewares' => 'cors,jwtAuth,basicAuth,authorization,validation,sanitation,multiTenancy,custom',
7
+    'middlewares' => 'cors,jwtAuth,basicAuth,authorization,validation,sanitation,multiTenancy,customization',
8 8
     'jwtAuth.time' => '1538207605',
9 9
     'jwtAuth.secret' => 'axpIrCGNGqxzx2R9dtXLIPUSqPo778uhb8CA0F4Hx',
10 10
     'basicAuth.passwordFile' => __DIR__ . DIRECTORY_SEPARATOR . '.htpasswd',
@@ -26,10 +26,10 @@ $settings = [
26 26
     'multiTenancy.handler' => function ($operation, $tableName) {
27 27
         return ($tableName == 'kunsthåndværk') ? ['user_id' => 1] : [];
28 28
     },
29
-    'custom.beforeHandler' => function ($operation, $tableName, $request, $environment) {
29
+    'customization.beforeHandler' => function ($operation, $tableName, $request, $environment) {
30 30
         $environment->start = 0.003/*microtime(true)*/;
31 31
     },
32
-    'custom.afterHandler' => function ($operation, $tableName, $response, $environment) {
32
+    'customization.afterHandler' => function ($operation, $tableName, $response, $environment) {
33 33
         if ($tableName == 'kunsthåndværk' && $operation == 'increment') {
34 34
             $response->addHeader('X-Time-Taken', 0.006/*microtime(true)*/ - $environment->start);
35 35
         }

Loading…
Cancel
Save