class DeletePostHandler

Traits

Properties

protected Dispatcher $events from DispatchEventsTrait
protected PostRepository $posts

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, PostRepository $posts)

No description

handle(DeletePost $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, PostRepository $posts)

Parameters

Dispatcher $events
PostRepository $posts

Post handle(DeletePost $command)

Parameters

DeletePost $command

Return Value

Post

Exceptions

PermissionDeniedException