77use Cake \Error \Debugger ;
88use Crud \Error \ExceptionRenderer ;
99use Crud \Listener \ApiQueryLogListener ;
10- use Neomerx \JsonApi \Document \Error ;
1110use Neomerx \JsonApi \Encoder \Encoder ;
12- use Neomerx \JsonApi \Exceptions \ErrorCollection ;
11+ use Neomerx \JsonApi \Schema \Error ;
12+ use Neomerx \JsonApi \Schema \ErrorCollection ;
1313use Zend \Diactoros \Stream ;
1414
1515/**
@@ -34,7 +34,7 @@ protected function _outputMessage($template)
3434 }
3535
3636 $ viewVars = $ this ->controller ->viewVars ;
37- $ code = $ this ->controller ->response ->getStatusCode (); // e.g. 404
37+ $ status = ( string ) $ this ->controller ->response ->getStatusCode (); // e.g. 404
3838 $ title = $ this ->controller ->response ->getReasonPhrase (); // e,g. Not Found
3939
4040 // Only set JSON API `detail` field if `message` viewVar field is not
@@ -48,12 +48,11 @@ protected function _outputMessage($template)
4848 $ errorCollection ->add (new Error (
4949 $ idx = null ,
5050 $ aboutLink = null ,
51- $ status = null ,
52- $ code ,
51+ $ typeLinks = null ,
52+ $ status ,
53+ $ code = null ,
5354 $ title ,
54- $ detail ,
55- $ source = null ,
56- $ meta = null
55+ $ detail
5756 ));
5857
5958 $ encoder = Encoder::instance ();
@@ -127,14 +126,13 @@ public function validation($exception)
127126 * - creating a new collection from CakePHP validation errors
128127 *
129128 * @param array $validationErrors CakePHP validation errors
130- * @return \Neomerx\JsonApi\Exceptions \ErrorCollection
129+ * @return \Neomerx\JsonApi\Schema \ErrorCollection
131130 */
132131 protected function _getNeoMerxErrorCollection ($ validationErrors )
133132 {
134- if (isset ($ validationErrors ['CrudJsonApiListener ' ]['NeoMerxErrorCollection ' ])) {
135- if (is_a ($ validationErrors ['CrudJsonApiListener ' ]['NeoMerxErrorCollection ' ], '\Neomerx\JsonApi\Exceptions\ErrorCollection ' )) {
136- return $ validationErrors ['CrudJsonApiListener ' ]['NeoMerxErrorCollection ' ];
137- }
133+ if (isset ($ validationErrors ['CrudJsonApiListener ' ]['NeoMerxErrorCollection ' ]) &&
134+ $ validationErrors ['CrudJsonApiListener ' ]['NeoMerxErrorCollection ' ] instanceof ErrorCollection) {
135+ return $ validationErrors ['CrudJsonApiListener ' ]['NeoMerxErrorCollection ' ];
138136 }
139137
140138 // Create new NeoMerx ErrorCollection from CakePHP validation errors
0 commit comments