@@ -10,19 +10,19 @@ |
||
10 | 10 | |
11 | 11 | public function register(Application $app) |
12 | 12 | { |
13 | - $app['alchemy_rest.middleware.parse_date_params'] = $app->share(function () { |
|
13 | + $app['alchemy_rest.middleware.parse_date_params'] = $app->share(function() { |
|
14 | 14 | return new Middleware\SetDateAttributesMiddlewareFactory(); |
15 | 15 | }); |
16 | 16 | |
17 | - $app['alchemy_rest.middleware.parse_list_params'] = $app->share(function () { |
|
17 | + $app['alchemy_rest.middleware.parse_list_params'] = $app->share(function() { |
|
18 | 18 | return new Middleware\SetPaginationAndSortAttributesMiddlewareFactory(); |
19 | 19 | }); |
20 | 20 | |
21 | - $app['alchemy_rest.middleware.transform_response'] = $app->share(function () { |
|
21 | + $app['alchemy_rest.middleware.transform_response'] = $app->share(function() { |
|
22 | 22 | return new Middleware\SetTransformAttributeMiddlewareFactory(); |
23 | 23 | }); |
24 | 24 | |
25 | - $app['alchemy_rest.middleware.json_encoder'] = $app->share(function () { |
|
25 | + $app['alchemy_rest.middleware.json_encoder'] = $app->share(function() { |
|
26 | 26 | return new Middleware\SetEncodingAttributeMiddlewareFactory(); |
27 | 27 | }); |
28 | 28 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $app->register(new MiddlewareServiceProvider()); |
39 | 39 | |
40 | 40 | $app['dispatcher'] = $app->share( |
41 | - $app->extend('dispatcher', function (EventDispatcherInterface $dispatcher) use ($app) { |
|
41 | + $app->extend('dispatcher', function(EventDispatcherInterface $dispatcher) use ($app) { |
|
42 | 42 | $this->bindRequestListeners($app, $dispatcher); |
43 | 43 | |
44 | 44 | // Bind exception |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | { |
70 | 70 | $app['alchemy_rest.paginate_options.offset_parameter'] = 'offset'; |
71 | 71 | $app['alchemy_rest.paginate_options.limit_parameter'] = 'limit'; |
72 | - $app['alchemy_rest.paginate_options_factory'] = $app->share(function () use ($app) { |
|
72 | + $app['alchemy_rest.paginate_options_factory'] = $app->share(function() use ($app) { |
|
73 | 73 | return new PaginationOptionsFactory( |
74 | 74 | $app['alchemy_rest.paginate_options.offset_parameter'], |
75 | 75 | $app['alchemy_rest.paginate_options.limit_parameter'] |
76 | 76 | ); |
77 | 77 | }); |
78 | 78 | |
79 | - $app['alchemy_rest.paginate_request_listener'] = $app->share(function () use ($app) { |
|
79 | + $app['alchemy_rest.paginate_request_listener'] = $app->share(function() use ($app) { |
|
80 | 80 | return new EventListener\PaginationParamRequestListener($app['alchemy_rest.paginate_options_factory']); |
81 | 81 | }); |
82 | 82 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $app['alchemy_rest.sort_options.sort_parameter'] = 'sort'; |
87 | 87 | $app['alchemy_rest.sort_options.direction_parameter'] = 'dir'; |
88 | 88 | $app['alchemy_rest.sort_options.multi_sort_parameter'] = 'sorts'; |
89 | - $app['alchemy_rest.sort_options_factory'] = $app->share(function () use ($app) { |
|
89 | + $app['alchemy_rest.sort_options_factory'] = $app->share(function() use ($app) { |
|
90 | 90 | return new SortOptionsFactory( |
91 | 91 | $app['alchemy_rest.sort_options.sort_parameter'], |
92 | 92 | $app['alchemy_rest.sort_options.direction_parameter'], |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | ); |
95 | 95 | }); |
96 | 96 | |
97 | - $app['alchemy_rest.sort_request_listener'] = $app->share(function () use ($app) { |
|
97 | + $app['alchemy_rest.sort_request_listener'] = $app->share(function() use ($app) { |
|
98 | 98 | return new EventListener\SortParamRequestListener($app['alchemy_rest.sort_options_factory']); |
99 | 99 | }); |
100 | 100 | } |
@@ -103,26 +103,26 @@ discard block |
||
103 | 103 | { |
104 | 104 | $app['alchemy_rest.date_parser.timezone'] = 'UTC'; |
105 | 105 | $app['alchemy_rest.date_parser.format'] = 'Y-m-d H:i:s'; |
106 | - $app['alchemy_rest.date_parser'] = $app->share(function () use ($app) { |
|
106 | + $app['alchemy_rest.date_parser'] = $app->share(function() use ($app) { |
|
107 | 107 | return new FormatDateParser( |
108 | 108 | $app['alchemy_rest.date_parser.timezone'], |
109 | 109 | $app['alchemy_rest.date_parser.format'] |
110 | 110 | ); |
111 | 111 | }); |
112 | 112 | |
113 | - $app['alchemy_rest.date_request_listener'] = $app->share(function () use ($app) { |
|
113 | + $app['alchemy_rest.date_request_listener'] = $app->share(function() use ($app) { |
|
114 | 114 | return new EventListener\DateParamRequestListener($app['alchemy_rest.date_parser']); |
115 | 115 | }); |
116 | 116 | } |
117 | 117 | |
118 | 118 | private function registerExceptionListener(Application $app) |
119 | 119 | { |
120 | - $app['alchemy_rest.exception_transformer'] = $app->share(function () use ($app) { |
|
120 | + $app['alchemy_rest.exception_transformer'] = $app->share(function() use ($app) { |
|
121 | 121 | return new DefaultExceptionTransformer($app['alchemy_rest.debug']); |
122 | 122 | }); |
123 | 123 | |
124 | 124 | $app['alchemy_rest.exception_handling_content_types'] = array('application/json'); |
125 | - $app['alchemy_rest.exception_listener'] = $app->share(function () use ($app) { |
|
125 | + $app['alchemy_rest.exception_listener'] = $app->share(function() use ($app) { |
|
126 | 126 | return new EventListener\ExceptionListener( |
127 | 127 | $app['alchemy_rest.content_type_matcher'], |
128 | 128 | $app['alchemy_rest.exception_transformer'], |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | |
134 | 134 | private function registerContentTypeMatcher(Application $app) |
135 | 135 | { |
136 | - $app['alchemy_rest.negotiator'] = $app->share(function () use ($app) { |
|
136 | + $app['alchemy_rest.negotiator'] = $app->share(function() use ($app) { |
|
137 | 137 | return new Negotiator(); |
138 | 138 | }); |
139 | - $app['alchemy_rest.content_type_matcher'] = $app->share(function () use ($app) { |
|
139 | + $app['alchemy_rest.content_type_matcher'] = $app->share(function() use ($app) { |
|
140 | 140 | return new ContentTypeMatcher($app['alchemy_rest.negotiator']); |
141 | 141 | }); |
142 | 142 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | $this->registerResponseEncoder($app); |
24 | 24 | |
25 | 25 | $app['dispatcher'] = $app->share( |
26 | - $app->extend('dispatcher', function (EventDispatcherInterface $dispatcher) use ($app) { |
|
26 | + $app->extend('dispatcher', function(EventDispatcherInterface $dispatcher) use ($app) { |
|
27 | 27 | $this->bindResultListeners($app, $dispatcher); |
28 | 28 | |
29 | 29 | return $dispatcher; |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | { |
59 | 59 | $app['alchemy_rest.decode_request_content_types'] = array('application/json'); |
60 | 60 | |
61 | - $app['alchemy_rest.decode_request_listener'] = $app->share(function () use ($app) { |
|
61 | + $app['alchemy_rest.decode_request_listener'] = $app->share(function() use ($app) { |
|
62 | 62 | return new EventListener\DecodeJsonBodyRequestListener($app['alchemy_rest.content_type_matcher']); |
63 | 63 | }); |
64 | 64 | |
65 | - $app['alchemy_rest.request_decoder'] = $app->protect(function (Request $request) use ($app) { |
|
65 | + $app['alchemy_rest.request_decoder'] = $app->protect(function(Request $request) use ($app) { |
|
66 | 66 | $app['alchemy_rest.decode_request_listener']->decodeBody($request); |
67 | 67 | }); |
68 | 68 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | private function registerResponseEncoder(Application $app) |
75 | 75 | { |
76 | - $app['alchemy_rest.encode_response_listener'] = $app->share(function () use ($app) { |
|
76 | + $app['alchemy_rest.encode_response_listener'] = $app->share(function() use ($app) { |
|
77 | 77 | return new EventListener\EncodeJsonResponseListener(); |
78 | 78 | }); |
79 | 79 | } |
@@ -84,39 +84,39 @@ discard block |
||
84 | 84 | */ |
85 | 85 | private function registerResponseListener(Application $app) |
86 | 86 | { |
87 | - $this->shareEventListener($app, 'alchemy_rest.transform_success_result_listener', function () { |
|
87 | + $this->shareEventListener($app, 'alchemy_rest.transform_success_result_listener', function() { |
|
88 | 88 | return new EventListener\SuccessResultListener(); |
89 | 89 | }); |
90 | 90 | |
91 | - $this->shareEventListener($app, 'alchemy_rest.transform_bad_request_listener', function () { |
|
91 | + $this->shareEventListener($app, 'alchemy_rest.transform_bad_request_listener', function() { |
|
92 | 92 | return new EventListener\BadRequestListener(); |
93 | 93 | }); |
94 | 94 | |
95 | - $this->shareEventListener($app, 'alchemy_rest.transform_request_accepted_listener', function () { |
|
95 | + $this->shareEventListener($app, 'alchemy_rest.transform_request_accepted_listener', function() { |
|
96 | 96 | return new EventListener\RequestAcceptedListener(); |
97 | 97 | }); |
98 | 98 | |
99 | - $this->shareEventListener($app, 'alchemy_rest.transform_resource_created_listener', function () use ($app) { |
|
99 | + $this->shareEventListener($app, 'alchemy_rest.transform_resource_created_listener', function() use ($app) { |
|
100 | 100 | return new EventListener\ResourceCreatedListener($app['alchemy_rest.array_transformer']); |
101 | 101 | }); |
102 | 102 | |
103 | 103 | |
104 | - $app['alchemy_rest.fractal_manager'] = $app->share(function () { |
|
104 | + $app['alchemy_rest.fractal_manager'] = $app->share(function() { |
|
105 | 105 | return new Manager(); |
106 | 106 | }); |
107 | 107 | |
108 | - $app['alchemy_rest.transformers_registry'] = $app->share(function () { |
|
108 | + $app['alchemy_rest.transformers_registry'] = $app->share(function() { |
|
109 | 109 | return new \Pimple(); |
110 | 110 | }); |
111 | 111 | |
112 | - $app['alchemy_rest.array_transformer'] = $app->share(function () use ($app) { |
|
112 | + $app['alchemy_rest.array_transformer'] = $app->share(function() use ($app) { |
|
113 | 113 | return new ArrayTransformer( |
114 | 114 | $app['alchemy_rest.fractal_manager'], |
115 | 115 | $app['alchemy_rest.transformers_registry'] |
116 | 116 | ); |
117 | 117 | }); |
118 | 118 | |
119 | - $app['alchemy_rest.transform_response_listener'] = $app->share(function () use ($app) { |
|
119 | + $app['alchemy_rest.transform_response_listener'] = $app->share(function() use ($app) { |
|
120 | 120 | return new EventListener\TransformResponseListener( |
121 | 121 | $app['alchemy_rest.array_transformer'], |
122 | 122 | $app['url_generator'] |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $request = $event->getRequest(); |
36 | 36 | $restAttributes = $request->attributes->get('_rest', []); |
37 | 37 | |
38 | - if (! isset($restAttributes['decode_request']) || ! $restAttributes['decode_request']) { |
|
38 | + if (!isset($restAttributes['decode_request']) || !$restAttributes['decode_request']) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $jsonBody = $request->getContent(false); |
57 | 57 | $decodedBody = json_decode($jsonBody, true); |
58 | 58 | |
59 | - if (! is_array($decodedBody)) { |
|
59 | + if (!is_array($decodedBody)) { |
|
60 | 60 | $decodedBody = array(); |
61 | 61 | } |
62 | 62 |