File tree Expand file tree Collapse file tree 4 files changed +56
-1
lines changed Expand file tree Collapse file tree 4 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 2
2
All notable changes to this project will be documented in this file. This project adheres to
3
3
[ Semantic Versioning] ( http://semver.org/ ) and [ this changelog format] ( http://keepachangelog.com/ ) .
4
4
5
+ ## [ 0.10.1] - 2017-08-15
6
+
7
+ ### Fixed
8
+ - [ #88 ] Fixed fatal error caused when resolving request objects out of the service container when there was no
9
+ inbound request bound in the service container.
10
+
5
11
## [ 0.10.0] - 2017-07-29
6
12
7
13
### Added
Original file line number Diff line number Diff line change @@ -215,7 +215,11 @@ protected function bindInboundRequest()
215
215
});
216
216
217
217
$ this ->app ->bind (DocumentInterface::class, function () {
218
- if (!$ document = json_api_request ()->getDocument ()) {
218
+ if (!$ request = json_api_request ()) {
219
+ throw new RuntimeException ('No inbound JSON API request. ' );
220
+ }
221
+
222
+ if (!$ document = $ request ->getDocument ()) {
219
223
throw new RuntimeException ('No request document on inbound JSON API request. ' );
220
224
}
221
225
Original file line number Diff line number Diff line change @@ -83,6 +83,18 @@ public function request()
83
83
return $ this ->container ->make ('json-api.request ' );
84
84
}
85
85
86
+ /**
87
+ * @return RequestInterface
88
+ */
89
+ public function requestOrFail ()
90
+ {
91
+ if (!$ request = $ this ->request ()) {
92
+ throw new RuntimeException ('No inbound JSON API request. ' );
93
+ }
94
+
95
+ return $ request ;
96
+ }
97
+
86
98
/**
87
99
* Get the API that is handling the inbound HTTP request.
88
100
*
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace CloudCreativity \LaravelJsonApi \Tests \Integration ;
4
+
5
+ use CloudCreativity \JsonApi \Contracts \Object \DocumentInterface ;
6
+ use CloudCreativity \JsonApi \Contracts \Object \RelationshipInterface ;
7
+ use CloudCreativity \JsonApi \Contracts \Object \ResourceObjectInterface ;
8
+ use CloudCreativity \JsonApi \Exceptions \RuntimeException ;
9
+
10
+ class ServicesTest extends TestCase
11
+ {
12
+
13
+ /**
14
+ * @see Issue 88
15
+ */
16
+ public function testDocumentWithoutInboundRequest ()
17
+ {
18
+ $ this ->expectException (RuntimeException::class);
19
+ app (DocumentInterface::class);
20
+ }
21
+
22
+ public function testResourceObjectWithoutInboundRequest ()
23
+ {
24
+ $ this ->expectException (RuntimeException::class);
25
+ app (ResourceObjectInterface::class);
26
+ }
27
+
28
+ public function testRelationshipObjectWithoutInboundRequest ()
29
+ {
30
+ $ this ->expectException (RuntimeException::class);
31
+ app (RelationshipInterface::class);
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments