@@ -316,22 +316,24 @@ class MustBeAuthorAssertion implements AssertionInterface
316
316
* Check if this assertion is true
317
317
*
318
318
* @param AuthorizationService $authorization
319
- * @param mixed $context
319
+ * @param mixed $post
320
320
*
321
321
* @return bool
322
322
*/
323
- public function assert(AuthorizationService $authorization, $context = null)
323
+ public function assert(AuthorizationService $authorization, $post = null)
324
324
{
325
- return $authorization->getIdentity() === $context ->getAuthor();
325
+ return $authorization->getIdentity() === $post ->getAuthor();
326
326
}
327
327
}
328
328
```
329
329
330
330
This simple ` MustBeAuthorAssertion ` will check against the current ` $authorization ` if it equals the identity of the
331
- current context Author. Now ` $context ` may sound a little strange for now but let me make it clear. The ` $context ` is
332
- usually the object of interest. Imagine a user calls ` http://my.dom/post/delete/42 ` , so obviously he wants to delete the
333
- Post-Entity with ID #42 . In this case Entity #42 is our Context! If you're wondering of how the context get's there, bare
334
- with me, we will get to this later.
331
+ current context Author. The second parameter is called the "context". A context can be anything (an object, a scalar,
332
+ an array...) and makes only sense in the context of the assertion.
333
+
334
+ Imagine a user calls ` http://my.dom/post/delete/42 ` , so obviously he wants to delete the Post-Entity with ID #42 . In
335
+ this case Entity #42 is our Context! If you're wondering of how the context get there, bare with me, we will get to
336
+ this later.
335
337
336
338
Now that we have written the Assertion, we want to make sure that this assertion will always be called, whenever we
337
339
check for the ` deletePost ` permission. We don't want others to delete our previous content! For this we have the so-
0 commit comments