API / Minn\Content / Reader

Reader final class

Minn\Content\Reader · public/minn/src/Minn/Content/Reader.php · 65 lines

Who is reading this request: their user id, whether they may read private content, whether they may edit a given post, and the post-password cookie they carry. Built once per surface by the engine, carried by the request's context, and consulted by the resolver, the queries, and the renderers.

Constants and properties

propreadonly int $userId

Promoted from the constructor.

propreadonly bool $readsPrivatePosts

Promoted from the constructor.

propreadonly bool $readsPrivatePages

Promoted from the constructor.

privatereadonly Closure $canEditPost

Promoted from the constructor.

propreadonly string $postPassword

Promoted from the constructor.

propreadonly string $sessionToken

Promoted from the constructor.

propreadonly array $roles

Promoted from the constructor.

Public

new__construct(int $userId, bool $readsPrivatePosts, bool $readsPrivatePages, Closure $canEditPost, string $postPassword, string $sessionToken = '', array $roles = array ( ))#
$canEditPostClosure(int): bool
staticanonymous(string $postPassword = ''): self#

The reader who is nobody: no session, no private posts, only the post password they typed.

staticforUser(int $userId, Minn\Auth\Capabilities $capabilities, string $postPassword = '', string $sessionToken = ''): self#

The reader a signed-in user is, asked of the capability engine: what they may read privately, what they may edit, and the roles they hold. User 0 is nobody, whatever the capabilities say.

staticcurrent(): self#

The reader of the request being answered. The runtime holds it (the context it was built with carries it), so there is one holder and a request cannot see the reader of the one before it. Without a runtime, on the command line and in unit tests, nobody is reading.

methodloggedIn(): bool#

Whether the reader has a session.

methodcanEdit(int $postId): bool#

Whether this reader may edit a given post.