Skip to content

typeDefinition() keys

The array returned by BaseNotify::typeDefinition(), passed to registerType(), or listed in config('notify-templates.types').

KeyTypeDefaultUsed byDescription
keystringthe class’s notifyKey() (discovery)registryUnique type key, e.g. OrderOrdered. Required in registerType() and config('notify-templates.types'); a discovered class may omit it. Must equal the class’s notifyKey() — discovery throws LogicException otherwise
namestring—your UIHuman-readable label
groupstring—getTypes($group), your UIGroup, e.g. order
weightint—your UISort order within a group; lower first. The registry doesn’t sort
descstring—your UIDescription, e.g. a tooltip
settingsstring[]—your UI, resolveDelay()Option keys editable per subscription, stored in notify_role_subscriptions.options. The package reads delay (minutes)
tokensarray—your UIToken hints: [['key' => '[order:number]', 'name' => 'Number']]
channelsstring[][]getTypeChannels()Channel slugs offered for this type in the UI; empty = config('notify-templates.channels'). Not used when sending
defaultsarray—sending, your UIdefaults.mail.subject / defaults.mail.body are the fallback when no template matches; other slots are editor placeholders only
user_configurablebooltruevia()false: user opt-outs and per-type channels are ignored, and an empty resolution falls back to default_channels. See User preferences
log_bodybooltruedelivery logfalse: the log stores the subject but never the body
buttonsarray[]buttons[['text' => 'Pay', 'url' => '[order:payUrl]']]; text may be a locale map. See Messenger buttons
buttons_by_rolearray—buttons['admin' => [...]] replaces buttons for a role; [] = no buttons
buttons_columnsint1buttonsButtons per row

Any other key is stored as is and returned by getType(); the package ignores it. See custom keys.

user_configurable is read from the registry by key; defaults, log_body and the button keys are read from the class’s own typeDefinition() when sending.

public static function typeDefinition(): array
{
return [
'key' => 'OrderOrdered',
'name' => 'Order placed',
'group' => 'order',
'weight' => 20,
'desc' => 'Sent when the customer places an order',
'channels' => ['mail', 'telegram'],
'settings' => ['delay'],
'tokens' => [
['key' => '[order:number]', 'name' => 'Order number'],
['key' => '[order:payUrl]', 'name' => 'Payment link'],
],
'defaults' => [
'mail' => ['subject' => 'Order placed', 'body' => 'Your order [order:number] has been received.'],
'messenger' => ['body' => 'New order [order:number]'],
],
'buttons' => [
['text' => ['uk' => 'Оплатити', 'en' => 'Pay'], 'url' => '[order:payUrl]'],
],
'buttons_by_role' => ['admin' => []],
];
}