Users final readonly class
Minn\Content\Users · public/minn/src/Minn/Content/Users.php · 286 lines
Used by 28 (show)
Constants and properties
| private | readonly Minn\Db $db | Promoted from the constructor. |
Public
| new | __construct(Minn\Db $db)# | ||||
| method | find(int $id): ?Minn\Content\UserRecord# | The user with this id, or null. | |||
| method | findByLogin(string $login): ?Minn\Content\UserRecord# | The user with this login, or null. | |||
| method | findByEmail(string $email): ?Minn\Content\UserRecord# | The user with this email, or null. | |||
| method | findBySlug(string $nicename): ?Minn\Content\UserRecord# | The user with this nicename, or null. | |||
| method | uniqueNicename(string $base, int $skipId = 0): string# | The unique-nicename rule: sanitized login, -2, -3 on collision. | |||
| method | createAccount(array $fields): int# | Inserts a user and the 14 default meta rows the reference writes. login: string, email: string, password: string, role: string, display_name: string, url?: string, nicename?: string, nickname?: string, first_name?: string, last_name?: string, description?: string, locale?: string, } $fields | |||
| static | defaultDisplayName(string $first, string $last, string $login): string# | The display name an account gets when none is given, as the reference picks it: first and last name, whichever of the two there is, or the login. The nickname plays no part. | |||
| method | insertAccount(array $fields): int# | A new account's row alone: the caller adds its meta and role, and keeps the count. @param array<string, mixed> $fields
| |||
| static | profileMeta(array $fields): array# | The twelve profile meta rows the reference gives a new account, in its order (the role's two follow).
@return array<string, string> | |||
| method | recount(): void# | Recounts the accounts into user_count, quietly. | |||
| method | deleteRow(int $id): void# | Removes the account's row alone: the caller removes its meta and keeps the count. | |||
| method | insert(array $columns): int# | Inserts a users row from column => value pairs and returns the new id.
| |||
| method | update(int $id, array $columns): void# | Sets the given columns on one user.
| |||
| method | delete(int $id): void# | Removes the user and their meta; their posts are reassigned or removed first by the caller. | |||
| method | ids(int $limit): array# | User ids in login order, optionally the first N. @return list<int> @return list<int> | |||
| method | setPassword(int $userId, string $hash): void# | Stores a new password hash and clears any pending reset key. | |||
| method | count(): int# | How many users the site has. | |||
| method | registeredAfter(string $since, int $limit): array# | The newest users registered since a site-local time, up to the limit. @return list<array> the newest registrations after a site-local timestamp | |||
| method | deleteMeta(int $userId, string $key): void# | Removes one meta key from a user. | |||
| method | withCapabilities(string $capabilitiesKey): array# | Every user with a capabilities row under the key given, as the old get_users_of_blog listed them: id twice, login, display name, email and the stored capabilities, in id order. @return list<array<string, string>> | |||
| method | withoutRole(string $capabilitiesKey, string $rolePattern): array# | The ids of users whose capabilities row names none of the roles (a pattern of their names). @return list<string> @return list<string> | |||
| method | meta(int $userId, string $key): ?string# | One usermeta value, raw. Serialized blobs come back as stored. | |||
| method | setMeta(int $userId, string $key, string $value): void# | Replaces one usermeta row. The (user_id, meta_key) pair carries no unique index on the stock schema, so this is a delete plus insert rather than an upsert. |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | record(?array $row): ?Minn\Content\UserRecord# |
| |||
| private | refreshCount(): void# | The user_count option, which the reference keeps current as accounts come and go. A site without the row is left without it. | |||
| private | writeAccount(array $fields): int# | The account's row and the fourteen meta rows the reference gives a new user, written as one unit by createAccount().
|
Nothing matches.