class PostReplyHandler

Traits

Properties

protected Dispatcher $events from DispatchEventsTrait
protected DiscussionRepository $discussions
protected NotificationSyncer $notifications
protected PostValidator $validator

Methods

dispatchEventsFor(object $entity, User $actor = null)

Dispatch all events for an entity.

assertPermission(bool $condition)

Ensure the current user is allowed to do something.

assertRegistered(User $actor)

Ensure the given actor is authenticated.

assertCan(User $actor, string $ability, mixed $arguments = [])

No description

assertAdmin(User $actor)

No description

__construct(Dispatcher $events, DiscussionRepository $discussions, NotificationSyncer $notifications, PostValidator $validator)

No description

CommentPost
handle(PostReply $command)

No description

Details

dispatchEventsFor(object $entity, User $actor = null)

Dispatch all events for an entity.

Parameters

object $entity
User $actor

protected assertPermission(bool $condition)

Ensure the current user is allowed to do something.

If the condition is not met, an exception will be thrown that signals the lack of permissions. This is about <em>authorization</em>, i.e. retrying such a request / operation without a change in permissions (or using another user account) is pointless.

Parameters

bool $condition

Exceptions

PermissionDeniedException

protected assertRegistered(User $actor)

Ensure the given actor is authenticated.

This will throw an exception for guest users, signaling that <em>authorization</em> failed. Thus, they could retry the operation after logging in (or using other means of authentication).

Parameters

User $actor

Exceptions

NotAuthenticatedException

protected assertCan(User $actor, string $ability, mixed $arguments = [])

Parameters

User $actor
string $ability
mixed $arguments

Exceptions

PermissionDeniedException

protected assertAdmin(User $actor)

Parameters

User $actor

Exceptions

PermissionDeniedException

__construct(Dispatcher $events, DiscussionRepository $discussions, NotificationSyncer $notifications, PostValidator $validator)

Parameters

Dispatcher $events
DiscussionRepository $discussions
NotificationSyncer $notifications
PostValidator $validator

CommentPost handle(PostReply $command)

Parameters

PostReply $command

Return Value

CommentPost

Exceptions

PermissionDeniedException