Neuron-PHP

ContactService
in package

Resolves contact form definitions from configuration and delivers submissions to the per-form recipient using the CMS email Sender.

Form definitions live under the contact settings section; each form declares its recipient plus its own configurable field list.

Table of Contents

Properties

$_basePath  : string
$_sender  : Sender|null
$_settings  : SettingManager

Methods

__construct()  : mixed
getDefaultFormKey()  : string
Get the default form key.
getFields()  : array<string|int, mixed>
Get the field definitions for a form.
getFormConfig()  : array<string|int, mixed>|null
Get the configuration for a single form.
resolveReplyTo()  : array{email: ?string, name: ?string}
Determine the reply-to email and name from the submitted values based on field role flags (reply_to / sender_name), falling back to fields named email / name.
send()  : bool
Send a contact submission for the given form key.
buildPlainBody()  : string
Build a simple plain-text email body from the configured fields.

Properties

Methods

__construct()

public __construct(SettingManager $settings[, Sender|null $sender = null ][, string|null $basePath = null ]) : mixed
Parameters
$settings : SettingManager
$sender : Sender|null = null

Optional Sender (injectable for testing)

$basePath : string|null = null

Base path for email template resolution

getDefaultFormKey()

Get the default form key.

public getDefaultFormKey() : string
Return values
string

getFields()

Get the field definitions for a form.

public getFields(string $key) : array<string|int, mixed>
Parameters
$key : string
Return values
array<string|int, mixed>

getFormConfig()

Get the configuration for a single form.

public getFormConfig(string $key) : array<string|int, mixed>|null
Parameters
$key : string
Return values
array<string|int, mixed>|null

Null when the form key is unknown

resolveReplyTo()

Determine the reply-to email and name from the submitted values based on field role flags (reply_to / sender_name), falling back to fields named email / name.

public resolveReplyTo(array<string|int, mixed> $fieldDefs, array<string|int, mixed> $values) : array{email: ?string, name: ?string}
Parameters
$fieldDefs : array<string|int, mixed>
$values : array<string|int, mixed>
Return values
array{email: ?string, name: ?string}

send()

Send a contact submission for the given form key.

public send(string $key, array<string|int, mixed> $values) : bool
Parameters
$key : string

Form key

$values : array<string|int, mixed>

Submitted field values keyed by field name

Return values
bool

True when the email was sent (or logged in test/log mode)

buildPlainBody()

Build a simple plain-text email body from the configured fields.

private buildPlainBody(array<string|int, mixed> $fieldDefs, array<string|int, mixed> $values) : string
Parameters
$fieldDefs : array<string|int, mixed>
$values : array<string|int, mixed>
Return values
string
On this page

Search results