phpbotgram

DefaultKeyBuilder
in package
implements KeyBuilder

FinalYes

Simple colon-joined key builder with an `fsm` prefix.

Mirrors aiogram.fsm.storage.base.DefaultKeyBuilder (aiogram/fsm/storage/base.py:42-99). Segment order matches upstream exactly:

<prefix>[:<botId>][:<businessConnectionId>]:<chatId>[:<threadId>]:<userId>[:<destiny>][:<part>]

Optional segments are controlled by constructor flags:

  • $withBotId — include botId
  • $withBusinessConnectionId — include businessConnectionId (only when non-null on the key)
  • $withDestiny — always include the destiny segment.

When $withDestiny is false (the default), the default destiny segment is omitted for compact keys, but non-default destiny values are still included. This keeps ordinary FSM keys stable while allowing scene-history and custom destiny slots to live in isolated backend keys.

Table of Contents

Interfaces

KeyBuilder
Contract for assembling a string key from an FSM {@see StorageKey} and an optional sub-record discriminator.

Properties

$prefix  : string
$separator  : string
$withBotId  : bool
$withBusinessConnectionId  : bool
$withDestiny  : bool

Methods

__construct()  : mixed
build()  : string
Assemble and return the storage key string.

Properties

$withBusinessConnectionId read-only

private bool $withBusinessConnectionId = false

Methods

__construct()

public __construct([string $prefix = 'fsm' ][, string $separator = ':' ][, bool $withBotId = false ][, bool $withBusinessConnectionId = false ][, bool $withDestiny = false ]) : mixed
Parameters
$prefix : string = 'fsm'

String prefix prepended to every generated key.

$separator : string = ':'

Token placed between each key segment.

$withBotId : bool = false

When true, the bot ID segment is included.

$withBusinessConnectionId : bool = false

When true, the business-connection-ID segment is included (only if the key's businessConnectionId is non-null).

$withDestiny : bool = false

When true, the destiny segment is always included. When false, only non-default destiny values are included.

build()

Assemble and return the storage key string.

public build(StorageKey $key[, null|StoragePart $part = null ]) : string
Parameters
$key : StorageKey

Contextual key.

$part : null|StoragePart = null

Optional sub-record discriminator; appended as the final segment when non-null.

Return values
string

Assembled key string.

On this page

Search results