class DnssecDsDnskeyController extends BaseController (View source)

Renders the DS and DNSKEY records page for a zone.

Properties

protected PDO $db from  BaseController
protected array $requestData from  BaseController
protected Request $httpRequest from  BaseController
protected MessageService $messageService from  BaseController
protected ConfigurationInterface $config from  BaseController
protected LoggerInterface $logger from  BaseController

Methods

void
run()

Abstract method to be implemented by subclasses to run the controller logic.

__construct(array $request, bool $authenticate = true, ControllerEnvironment|null $environment = null)

Constructor for BaseController.

static void
bindContext(BootContext $context)

Hands the booted context to every controller the router builds.

static BootContext
requestContext()

No description

bool
requiresCsrfValidation()

Whether a POST to this controller must carry a valid _token.

bool
isPost()

Checks if the current request is a POST request.

getConfig()

Gets the application configuration.

mixed
getModuleConfig(string $module, string $key, mixed $default = null)

Get a module config value with legacy fallback.

void
render(string $template, array $params)

Renders a template with the given parameters.

getPdnsCapabilities()

Build a PdnsCapabilities snapshot from the session-cached PowerDNS version. Reads the cache without a network call while it is fresh; once the entry expires it runs one rate-limited refresh, otherwise every capability gate would silently turn off five minutes after the last dashboard visit and hide catalog zones and newer record types.

array|null
getCachedPdnsServerInfo(bool $allowExpired = true)

The server info the page chrome reads for zone type labels. Never calls PowerDNS (it renders on login pages too); the dashboard refreshes the cache, and an expired entry still beats flipping labels to Master/Slave.

getRecordTypeCapabilities()

Capabilities to use when filtering selectable record types, or null to skip version filtering entirely.

void
refreshPdnsCapabilities()

Trigger a session-cached refresh of PowerDNS version + capabilities.

void
validateCsrfToken()

Validates the CSRF token from the request.

void
redirect(string $url, array $args = [])

Redirects to a specified URL with optional arguments.

void
setMessage(string $script, string $type, string $content)

Sets a message to be displayed for a specific script.

array|null
getMessages(string $script)

Gets messages for a specific script.

void
checkCondition(bool $condition, string $errorMessage)

Checks a condition and displays an error message if the condition is true.

never
halt(string $kind, string $target)

Ends the request after its response was written; see RequestHalted.

never
sendAndHalt(Response $response)

Sends a prepared response and ends the request; the API controllers answer every request this way.

services()

Lazily builds the shared service factory so per-request memoized instances (backend provider, permission cache) span all accessors.

moduleServices()

The same factory narrowed to the module SDK contract; module controllers use this instead of services() so their core dependencies stay declared.

backendCapabilities()

The request's backend as a capability probe; controllers ask it what the backend can do instead of re-reading dns.backend from the configuration.

bool
isApiBackend()

Backend identity, for the few places that report it rather than act on a capability (the is_api_backend template variable, the API error banner).

array
apiEscapeRiskRrsets(int $zoneId, string $zoneName)

RRsets of the zone that PowerDNS Auth 5.1.x would alter on the next API write to them; always empty on the SQL backend, which writes content as entered.

int
resolveRowsPerPage(int $fallback = PaginationService::DEFAULT_ROWS_PER_PAGE)

Resolves the page size for a listing: the request value wins, then the user's stored preference, then interface.rows_per_page with $fallback when unset.

string
presentPagination(int $totalItems, int $itemsPerPage, string $path, array $queryParams = [])

Renders a pagination widget for a paginated listing.

array
paginationVariables(int $totalItems, int $itemsPerPage, string $path, array $queryParams = [])

The pagination (pre-rendered string, kept for theme forks) and pagination_items (for _partials/pagination.html) template variables for a paginated listing.

bool
hasPermission(string $permission)

Check if the logged-in user has the given permission

string
getViewPermissionLevel()

The logged-in user's zone view level: "all", "own" or "none"

bool
canViewZones()

Whether the logged-in user may view any zone; flashes the refusal when not, so a zone lookup skipped on "none" still explains itself on the page.

bool
isZoneOwner(int $zoneId)

Check if the logged-in user owns the given zone directly or via group membership

void
requireZoneView(int $zoneId)

Stops the request unless the current user may open the zone (showError exits).

createZoneManagementService()

The zone service the API uses, told what the connected server supports.

createZoneCreateService()

The zone creation flow of the add-zone forms, told what the connected server supports.

moduleRegistry()

The request's loaded module registry.

array
moduleCapabilityData(string $capability, array $context = [])

What the enabled modules offer for a capability (wizard actions, lookup links, export formats), honouring each module's admin restriction.

bool
moduleProvides(string $capability)

No description

changeApproval()

Change-approval answers for one user and zone; callers pass the user id, usually getCurrentUserId(). One instance per request.

string
changeApprovalModeForZone(int $zoneId)

No description

directWriteZoneGate()

For a write that lands in a zone other than the one the request was checked against, such as the PTR of an A record: refused where the user must file a change request.

int|null
getCurrentUserId()

Get current user ID

array
assignableOwners(array $users)

The users a new zone may be given to: everyone when the create path lets the caller assign other owners and they may see other users, otherwise only the current user.

int|string
preservedOwnerChoice(array $assignableOwners, mixed $ownerInput)

The owner an add-zone form shows again after a failed submit: the posted id when the picker can offer it, '' for an explicit "no user owner", otherwise the current user.

void
reportZoneWrite(string $script, ZoneWriteResult $result, string $successMessage)

Flash the outcome of a zone write to a page: the given text on success, the result's reason on failure.

session()

The request's session, shared by every collaborator this controller builds.

getUserContextService()

Get the user context service

void
setCurrentPage(string $page)

Sets the current page identifier used for navigation highlighting.

void
setPageTitle(string $title)

Sets the page title displayed in the header.

void
checkPermission(string $permission, string $errorMessage)

Checks if the user has a specific permission and displays an error message if not.

int
requireNumericParam(string $name, string|null $error = null)

Reads a positive integer request parameter (an id) or ends the request with an error page.

void
renderNotFound()

Answers with the standard 404 page, for routes whose feature is switched off.

void
showError(string $error, string|null $recordName = null)

Displays an error message.

array
getRequest()

Gets the request data.

string
getSafeRequestValue(string $key)

Gets a safe value from the request data.

void
setValidationConstraints(array $constraints)

Sets validation constraints for the request data.

bool
doValidateRequest(array|null $data = null)

Validates the request data.

void
showFirstValidationError(array|null $data = null)

Displays the first validation error.

void
addSystemMessage(string $type, string $content)

Adds a system-wide message that will be displayed on any page

void
showKeys(int $zone_id, $pdnssec_use, bool $can_manage_dnssec)

No description

Details

void run()

Abstract method to be implemented by subclasses to run the controller logic.

Return Value

void

__construct(array $request, bool $authenticate = true, ControllerEnvironment|null $environment = null)

Constructor for BaseController.

Parameters

array $request

The request data.

bool $authenticate

Whether to authenticate the user.

ControllerEnvironment|null $environment

The collaborators to use; without one they come from the kernel context the router bound for this request, which also checks the extensions, the locale and the session.

static void bindContext(BootContext $context)

Hands the booted context to every controller the router builds.

Controllers are constructed by class name with request data only, so the router cannot pass it through their constructors.

Parameters

BootContext $context

Return Value

void

static protected BootContext requestContext()

No description

Return Value

BootContext

protected bool requiresCsrfValidation()

Whether a POST to this controller must carry a valid _token.

Controllers that authenticate statelessly, receive third-party posts, or validate their own flow-scoped token override this and return false.

Return Value

bool

bool isPost()

Checks if the current request is a POST request.

Return Value

bool

True if the request method is POST, false otherwise.

ConfigurationInterface getConfig()

Gets the application configuration.

Return Value

ConfigurationInterface

The application configuration.

protected mixed getModuleConfig(string $module, string $key, mixed $default = null)

Get a module config value with legacy fallback.

Checks modules.. first, then falls back to . for backward compatibility with pre-module config layouts.

Parameters

string $module
string $key
mixed $default

Return Value

mixed

void render(string $template, array $params)

Renders a template with the given parameters.

Parameters

string $template

The template to render.

array $params

The parameters to pass to the template.

Return Value

void

protected PdnsCapabilities getPdnsCapabilities()

Build a PdnsCapabilities snapshot from the session-cached PowerDNS version. Reads the cache without a network call while it is fresh; once the entry expires it runs one rate-limited refresh, otherwise every capability gate would silently turn off five minutes after the last dashboard visit and hide catalog zones and newer record types.

A failed refresh keeps the expired entry rather than flipping the UI to "unknown" over a transient API error.

Return Value

PdnsCapabilities

protected array|null getCachedPdnsServerInfo(bool $allowExpired = true)

The server info the page chrome reads for zone type labels. Never calls PowerDNS (it renders on login pages too); the dashboard refreshes the cache, and an expired entry still beats flipping labels to Master/Slave.

The dashboard passes false so its version badge shows only a fresh value.

Parameters

bool $allowExpired

Return Value

array|null

protected PdnsCapabilities|null getRecordTypeCapabilities()

Capabilities to use when filtering selectable record types, or null to skip version filtering entirely.

Only API backends can report their PowerDNS version, so only there can we safely hide types a newer-than-server feature would need. On SQL backends the version is never known, and strict-unknown filtering would wrongly and permanently drop valid types (HTTPS, SVCB, ZONEMD, ...) from every form. Returning null there leaves the configured/default type list intact.

Return Value

PdnsCapabilities|null

protected void refreshPdnsCapabilities()

Trigger a session-cached refresh of PowerDNS version + capabilities.

Runs in both API and SQL backend modes: the version display is useful in either mode whenever pdns_api is configured, even though capability gates only matter for API mode. getPdnsCapabilities() calls this itself once the cached entry expires; call it directly only where a fresh version matters more than the cached one - e.g. the dashboard.

Return Value

void

void validateCsrfToken()

Validates the CSRF token from the request.

Return Value

void

void redirect(string $url, array $args = [])

Redirects to a specified URL with optional arguments.

Automatically prepends base_url_prefix for subfolder deployments.

Parameters

string $url

The URL to redirect to.

array $args

The arguments to pass as query parameters.

Return Value

void

void setMessage(string $script, string $type, string $content)

Sets a message to be displayed for a specific script.

Parameters

string $script

The script to set the message for.

string $type

The type of message (error, warning, success, info).

string $content

The content of the message.

Return Value

void

array|null getMessages(string $script)

Gets messages for a specific script.

Parameters

string $script

The script to get messages for.

Return Value

array|null

The messages for the script, or null if no messages are set.

void checkCondition(bool $condition, string $errorMessage)

Checks a condition and displays an error message if the condition is true.

Parameters

bool $condition

The condition to check.

string $errorMessage

The error message to display if the condition is true.

Return Value

void

protected never halt(string $kind, string $target)

Ends the request after its response was written; see RequestHalted.

Parameters

string $kind
string $target

Return Value

never

protected never sendAndHalt(Response $response)

Sends a prepared response and ends the request; the API controllers answer every request this way.

Parameters

Response $response

Return Value

never

protected ControllerServiceFactory services()

Lazily builds the shared service factory so per-request memoized instances (backend provider, permission cache) span all accessors.

protected ModuleServices moduleServices()

The same factory narrowed to the module SDK contract; module controllers use this instead of services() so their core dependencies stay declared.

Return Value

ModuleServices

protected BackendCapabilitiesInterface backendCapabilities()

The request's backend as a capability probe; controllers ask it what the backend can do instead of re-reading dns.backend from the configuration.

protected bool isApiBackend()

Backend identity, for the few places that report it rather than act on a capability (the is_api_backend template variable, the API error banner).

Return Value

bool

protected array apiEscapeRiskRrsets(int $zoneId, string $zoneName)

RRsets of the zone that PowerDNS Auth 5.1.x would alter on the next API write to them; always empty on the SQL backend, which writes content as entered.

Parameters

int $zoneId
string $zoneName

Return Value

array

protected int resolveRowsPerPage(int $fallback = PaginationService::DEFAULT_ROWS_PER_PAGE)

Resolves the page size for a listing: the request value wins, then the user's stored preference, then interface.rows_per_page with $fallback when unset.

Parameters

int $fallback

Return Value

int

protected string presentPagination(int $totalItems, int $itemsPerPage, string $path, array $queryParams = [])

Renders a pagination widget for a paginated listing.

$path is the route with the {PageNumber} placeholder already in place (e.g. '/zones/forward?start={PageNumber}'). $queryParams are extra key => value pairs appended urlencoded, in order, skipping absent and blank values.

Parameters

int $totalItems
int $itemsPerPage
string $path
array $queryParams

Return Value

string

protected array paginationVariables(int $totalItems, int $itemsPerPage, string $path, array $queryParams = [])

The pagination (pre-rendered string, kept for theme forks) and pagination_items (for _partials/pagination.html) template variables for a paginated listing.

Parameters

int $totalItems
int $itemsPerPage
string $path
array $queryParams

Return Value

array

protected ZoneSortingService createZoneSortingService()

No description

Return Value

ZoneSortingService

protected bool hasPermission(string $permission)

Check if the logged-in user has the given permission

Parameters

string $permission

Return Value

bool

protected string getViewPermissionLevel()

The logged-in user's zone view level: "all", "own" or "none"

Return Value

string

protected bool canViewZones()

Whether the logged-in user may view any zone; flashes the refusal when not, so a zone lookup skipped on "none" still explains itself on the page.

Return Value

bool

protected bool isZoneOwner(int $zoneId)

Check if the logged-in user owns the given zone directly or via group membership

Parameters

int $zoneId

Return Value

bool

protected void requireZoneView(int $zoneId)

Stops the request unless the current user may open the zone (showError exits).

Parameters

int $zoneId

Return Value

void

protected ZoneManagementService createZoneManagementService()

The zone service the API uses, told what the connected server supports.

Return Value

ZoneManagementService

protected ZoneCreateService createZoneCreateService()

The zone creation flow of the add-zone forms, told what the connected server supports.

Return Value

ZoneCreateService

protected ModuleRegistry moduleRegistry()

The request's loaded module registry.

Return Value

ModuleRegistry

protected array moduleCapabilityData(string $capability, array $context = [])

What the enabled modules offer for a capability (wizard actions, lookup links, export formats), honouring each module's admin restriction.

Parameters

string $capability
array $context

Placeholders for the modules' url patterns, e.g. zone_id

Return Value

array

protected bool moduleProvides(string $capability)

No description

Parameters

string $capability

Return Value

bool

protected ChangeApprovalContext changeApproval()

Change-approval answers for one user and zone; callers pass the user id, usually getCurrentUserId(). One instance per request.

Return Value

ChangeApprovalContext

protected string changeApprovalModeForZone(int $zoneId)

No description

Parameters

int $zoneId

Return Value

string

protected Closure directWriteZoneGate()

For a write that lands in a zone other than the one the request was checked against, such as the PTR of an A record: refused where the user must file a change request.

Return Value

Closure

protected int|null getCurrentUserId()

Get current user ID

Return Value

int|null

protected array assignableOwners(array $users)

The users a new zone may be given to: everyone when the create path lets the caller assign other owners and they may see other users, otherwise only the current user.

Parameters

array $users

Rows with an 'id' key

Return Value

array

protected int|string preservedOwnerChoice(array $assignableOwners, mixed $ownerInput)

The owner an add-zone form shows again after a failed submit: the posted id when the picker can offer it, '' for an explicit "no user owner", otherwise the current user.

Parameters

array $assignableOwners
mixed $ownerInput

The raw posted value, if any

Return Value

int|string

protected void reportZoneWrite(string $script, ZoneWriteResult $result, string $successMessage)

Flash the outcome of a zone write to a page: the given text on success, the result's reason on failure.

Parameters

string $script
ZoneWriteResult $result
string $successMessage

Return Value

void

protected SessionInterface session()

The request's session, shared by every collaborator this controller builds.

Return Value

SessionInterface

protected UserContextService getUserContextService()

Get the user context service

Return Value

UserContextService

protected void setCurrentPage(string $page)

Sets the current page identifier used for navigation highlighting.

Parameters

string $page

The page identifier

Return Value

void

protected void setPageTitle(string $title)

Sets the page title displayed in the header.

Parameters

string $title

The page title

Return Value

void

void checkPermission(string $permission, string $errorMessage)

Checks if the user has a specific permission and displays an error message if not.

Parameters

string $permission

The permission to check.

string $errorMessage

The error message to display if the user does not have the permission.

Return Value

void

protected int requireNumericParam(string $name, string|null $error = null)

Reads a positive integer request parameter (an id) or ends the request with an error page.

Parameters

string $name
string|null $error

Return Value

int

protected void renderNotFound()

Answers with the standard 404 page, for routes whose feature is switched off.

Return Value

void

void showError(string $error, string|null $recordName = null)

Displays an error message.

Parameters

string $error

The error message to display.

string|null $recordName

Optional record name for context

Return Value

void

array getRequest()

Gets the request data.

Return Value

array

The request data.

string getSafeRequestValue(string $key)

Gets a safe value from the request data.

Parameters

string $key

The key to get the value for.

Return Value

string

The safe value.

void setValidationConstraints(array $constraints)

Sets validation constraints for the request data.

Parameters

array $constraints

The validation constraints.

Return Value

void

bool doValidateRequest(array|null $data = null)

Validates the request data.

Parameters

array|null $data

Optional data to validate. If not provided, uses $this->requestData

Return Value

bool

True if the request data is valid, false otherwise.

void showFirstValidationError(array|null $data = null)

Displays the first validation error.

Parameters

array|null $data

Optional data to validate. If not provided, uses $this->requestData

Return Value

void

void addSystemMessage(string $type, string $content)

Adds a system-wide message that will be displayed on any page

Parameters

string $type

The type of message (error, warning, success, info)

string $content

The content of the message

Return Value

void

void showKeys(int $zone_id, $pdnssec_use, bool $can_manage_dnssec)

No description

Parameters

int $zone_id
$pdnssec_use
bool $can_manage_dnssec

Return Value

void