AddSupermasterController
class AddSupermasterController extends BaseController (View source)
Handles the add-supermaster form: validates the IP and nameserver, then stores the supermaster entry.
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
Abstract method to be implemented by subclasses to run the controller logic.
Constructor for BaseController.
Whether a POST to this controller must carry a valid _token.
Get a module config value with legacy fallback.
Renders a template with the given parameters.
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.
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.
Capabilities to use when filtering selectable record types, or null to skip version filtering entirely.
Trigger a session-cached refresh of PowerDNS version + capabilities.
Redirects to a specified URL with optional arguments.
Sets a message to be displayed for a specific script.
Checks a condition and displays an error message if the condition is true.
Ends the request after its response was written; see RequestHalted.
Sends a prepared response and ends the request; the API controllers answer every request this way.
Lazily builds the shared service factory so per-request memoized instances (backend provider, permission cache) span all accessors.
The same factory narrowed to the module SDK contract; module controllers use this instead of services() so their core dependencies stay declared.
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.
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).
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.
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.
Renders a pagination widget for a paginated listing.
The pagination (pre-rendered string, kept for theme forks) and pagination_items
(for _partials/pagination.html) template variables for a paginated listing.
Check if the logged-in user has the given permission
The logged-in user's zone view level: "all", "own" or "none"
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.
Check if the logged-in user owns the given zone directly or via group membership
Stops the request unless the current user may open the zone (showError exits).
The zone service the API uses, told what the connected server supports.
The zone creation flow of the add-zone forms, told what the connected server supports.
What the enabled modules offer for a capability (wizard actions, lookup links, export formats), honouring each module's admin restriction.
Change-approval answers for one user and zone; callers pass the user id, usually getCurrentUserId(). One instance per request.
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.
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.
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.
Flash the outcome of a zone write to a page: the given text on success, the result's reason on failure.
The request's session, shared by every collaborator this controller builds.
Sets the current page identifier used for navigation highlighting.
Checks if the user has a specific permission and displays an error message if not.
Reads a positive integer request parameter (an id) or ends the request with an error page.
Answers with the standard 404 page, for routes whose feature is switched off.
Displays an error message.
Gets a safe value from the request data.
Sets validation constraints for the request data.
Displays the first validation error.
Adds a system-wide message that will be displayed on any page
Details
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.
Controllers are constructed by class name with request data only, so the router cannot pass it through their constructors.
static protected BootContext
requestContext()
No description
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.
bool
isPost()
Checks if the current request is a POST request.
ConfigurationInterface
getConfig()
Gets the application configuration.
protected mixed
getModuleConfig(string $module, string $key, mixed $default = null)
Get a module config value with legacy fallback.
Checks modules.
void
render(string $template, array $params)
Renders a template with the given parameters.
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.
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.
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.
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.
void
validateCsrfToken()
Validates the CSRF token from the request.
void
redirect(string $url, array $args = [])
Redirects to a specified URL with optional arguments.
Automatically prepends base_url_prefix for subfolder deployments.
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.
protected never
halt(string $kind, string $target)
Ends the request after its response was written; see RequestHalted.
protected never
sendAndHalt(Response $response)
Sends a prepared response and ends the request; the API controllers answer every request this way.
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.
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).
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.
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.
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.
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.
protected ZoneSortingService
createZoneSortingService()
No description
protected bool
hasPermission(string $permission)
Check if the logged-in user has the given permission
protected string
getViewPermissionLevel()
The logged-in user's zone view level: "all", "own" or "none"
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.
protected bool
isZoneOwner(int $zoneId)
Check if the logged-in user owns the given zone directly or via group membership
protected void
requireZoneView(int $zoneId)
Stops the request unless the current user may open the zone (showError exits).
protected ZoneManagementService
createZoneManagementService()
The zone service the API uses, told what the connected server supports.
protected ZoneCreateService
createZoneCreateService()
The zone creation flow of the add-zone forms, told what the connected server supports.
protected ModuleRegistry
moduleRegistry()
The request's loaded module registry.
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.
protected bool
moduleProvides(string $capability)
No description
protected ChangeApprovalContext
changeApproval()
Change-approval answers for one user and zone; callers pass the user id, usually getCurrentUserId(). One instance per request.
protected string
changeApprovalModeForZone(int $zoneId)
No description
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.
protected int|null
getCurrentUserId()
Get current user ID
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.
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.
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.
protected SessionInterface
session()
The request's session, shared by every collaborator this controller builds.
protected UserContextService
getUserContextService()
Get the user context service
protected void
setCurrentPage(string $page)
Sets the current page identifier used for navigation highlighting.
protected 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.
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.
protected 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