Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Commit df3b0a7

Browse files
committed
Fix doc
1 parent a37735c commit df3b0a7

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

docs/07. Cookbook.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,22 +316,24 @@ class MustBeAuthorAssertion implements AssertionInterface
316316
* Check if this assertion is true
317317
*
318318
* @param AuthorizationService $authorization
319-
* @param mixed $context
319+
* @param mixed $post
320320
*
321321
* @return bool
322322
*/
323-
public function assert(AuthorizationService $authorization, $context = null)
323+
public function assert(AuthorizationService $authorization, $post = null)
324324
{
325-
return $authorization->getIdentity() === $context->getAuthor();
325+
return $authorization->getIdentity() === $post->getAuthor();
326326
}
327327
}
328328
```
329329

330330
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.
335337

336338
Now that we have written the Assertion, we want to make sure that this assertion will always be called, whenever we
337339
check for the `deletePost` permission. We don't want others to delete our previous content! For this we have the so-

0 commit comments

Comments
 (0)