@@ -138,26 +138,18 @@ public function beforeHandle(EventInterface $event): void
138138 * `?include=` query parameter was passed because that would override/break previously generated data.
139139 *
140140 * @param \Cake\Event\EventInterface $event Event
141- * @return null
141+ * @return void
142142 */
143- public function afterFind (EventInterface $ event )
143+ public function afterFind (EventInterface $ event ): void
144144 {
145145 if (!$ this ->_request ()->is ('get ' )) {
146- return null ;
146+ return ;
147147 }
148148
149149 // set property so we can check inside `_renderWithResources()`
150150 if (!empty ($ event ->getSubject ()->query ->getContain ())) {
151151 $ this ->_ControllerHasSetContain = true ;
152-
153- return null ;
154152 }
155-
156- if ($ this ->getConfig ('include ' )) {
157- return null ;
158- }
159-
160- return null ;
161153 }
162154
163155 /**
@@ -203,16 +195,12 @@ public function beforeSave(EventInterface $event): void
203195 // hasMany found in the entity, extract ids from the request data
204196 $ primaryResourceId = $ this ->_controller ()->getRequest ()->getData ('id ' );
205197
206- /**
207- * @var array $hasManyIds
208- */
198+ /** @var array $hasManyIds */
209199 $ hasManyIds = Hash::extract ($ this ->_controller ()->getRequest ()->getData ($ key ), '{n}.id ' );
210200 $ hasManyTable = $ this ->getTableLocator ()->get ($ associationName );
211201
212202 // query database only for hasMany that match both passed id and the id of the primary resource
213- /**
214- * @var string $entityForeignKey
215- */
203+ /** @var string $entityForeignKey */
216204 $ entityForeignKey = $ hasManyTable ->getAssociation ($ entity ->getSource ())->getForeignKey ();
217205 $ primaryKey = current ((array )$ hasManyTable ->getPrimaryKey ());
218206 $ query = $ hasManyTable ->find ()
@@ -245,17 +233,21 @@ public function beforeSave(EventInterface $event): void
245233 * afterSave() event.
246234 *
247235 * @param \Cake\Event\EventInterface $event Event
248- * @return bool|null
236+ * @return void
249237 */
250- public function afterSave (EventInterface $ event ): ? bool
238+ public function afterSave (EventInterface $ event ): void
251239 {
252240 if (!$ event ->getSubject ()->success ) {
253- return false ;
241+ $ event ->setResult (false );
242+
243+ return ;
254244 }
255245
256246 // `created` will be set for add actions, `id` for edit actions
257247 if (!$ event ->getSubject ()->created && !$ event ->getSubject ()->id ) {
258- return false ;
248+ $ event ->setResult (false );
249+
250+ return ;
259251 }
260252
261253 // The `add`action (new Resource) MUST respond with HTTP Status Code 201,
@@ -269,8 +261,6 @@ public function afterSave(EventInterface $event): ?bool
269261 */
270262 $ subject = $ event ->getSubject ();
271263 $ this ->render ($ subject );
272-
273- return null ;
274264 }
275265
276266 /**
@@ -281,17 +271,17 @@ public function afterSave(EventInterface $event): ?bool
281271 * been implemented here yet. http://jsonapi.org/format/#crud-deleting
282272 *
283273 * @param \Cake\Event\EventInterface $event Event
284- * @return bool|null
274+ * @return void
285275 */
286- public function afterDelete (EventInterface $ event ): ? bool
276+ public function afterDelete (EventInterface $ event ): void
287277 {
288278 if (!$ event ->getSubject ()->success ) {
289- return false ;
279+ $ event ->setResult (false );
280+
281+ return ;
290282 }
291283
292284 $ this ->_controller ()->setResponse ($ this ->_controller ()->getResponse ()->withStatus (204 ));
293-
294- return null ;
295285 }
296286
297287 /**
0 commit comments