class RecordManager implements RecordManagerInterface (View source)

Service class for managing DNS records

Methods

__construct(PDO $db, ConfigurationManager $config, DnsRecordValidationServiceInterface $validationService, SOARecordManagerInterface $soaRecordManager, DomainRepositoryInterface $domainRepository, DnsBackendProvider|null $backendProvider = null, LoggerInterface|null $logger = null, RecordChangeLogger|null $changeLogger = null, UserContextService|null $userContext = null)

Constructor

bool
addRecord(int $zone_id, string $name, string $type, string $content, int $ttl, mixed $prio)

Add a record

addRecordGetId(int $zone_id, string $name, string $type, string $content, int $ttl, mixed $prio, int $disabled = 0, bool $finalizeZone = true)

Add a record and return its ID

static bool
recordFieldsDiffer(array $before, array $after)

Whether two stored copies of a record differ in any field that PowerDNS serves.

editRecord(array $record, bool $finalizeZone = true, array|null $comment = null)

Edit a record

deleteRecord(int|string $rid, bool $finalizeZone = true)

Delete a record by a given record id

void
finalizeZone(int $zoneId, bool $bumpSerial = true)

What every single write ends with: bump the serial (unless told not to) and rectify. Batch callers pass finalizeZone=false to the writes and call this once when they are done; one holding a transaction bumps the serial inside it and calls this with bumpSerial=false after the commit, since PowerDNS rectifies from committed rows.

static bool
deleteRecordZoneTempl(PDO $db, int|string $rid)

Delete record reference to zone template

static string
getZoneComment(PDO $db, int $zone_id)

Get Zone comment

bool
editZoneComment(int $zone_id, string $comment)

Edit the zone comment

Details

__construct(PDO $db, ConfigurationManager $config, DnsRecordValidationServiceInterface $validationService, SOARecordManagerInterface $soaRecordManager, DomainRepositoryInterface $domainRepository, DnsBackendProvider|null $backendProvider = null, LoggerInterface|null $logger = null, RecordChangeLogger|null $changeLogger = null, UserContextService|null $userContext = null)

Constructor

Parameters

PDO $db

Database connection

ConfigurationManager $config

Configuration manager

DnsRecordValidationServiceInterface $validationService

DNS record validation service

SOARecordManagerInterface $soaRecordManager

SOA record manager

DomainRepositoryInterface $domainRepository

Domain repository

DnsBackendProvider|null $backendProvider

DNS backend provider (auto-created if null)

LoggerInterface|null $logger
RecordChangeLogger|null $changeLogger
UserContextService|null $userContext

bool addRecord(int $zone_id, string $name, string $type, string $content, int $ttl, mixed $prio)

Add a record

This function validates it if correct it inserts it into the database.

Parameters

int $zone_id

Zone ID

string $name

Name part of record

string $type

Type of record

string $content

Content of record

int $ttl

Time-To-Live of record

mixed $prio

Priority of record

Return Value

bool

true if successful

RecordWriteResult addRecordGetId(int $zone_id, string $name, string $type, string $content, int $ttl, mixed $prio, int $disabled = 0, bool $finalizeZone = true)

Add a record and return its ID

This function validates and inserts a record into the database, returning the new record's ID for use with per-record comments.

Parameters

int $zone_id

Zone ID

string $name

Name part of record

string $type

Type of record

string $content

Content of record

int $ttl

Time-To-Live of record

mixed $prio

Priority of record

int $disabled

Whether the record is created in disabled state (0 or 1)

bool $finalizeZone

Bump the serial and rectify; a batch caller does that once itself

Return Value

RecordWriteResult

The new record id, or the reason the write was refused

static bool recordFieldsDiffer(array $before, array $after)

Whether two stored copies of a record differ in any field that PowerDNS serves.

Parameters

array $before

Record row as stored before the edit

array $after

Record row as stored after the edit

Return Value

bool

RecordWriteResult editRecord(array $record, bool $finalizeZone = true, array|null $comment = null)

Edit a record

This function validates it if correct it inserts it into the database.

Parameters

array $record

Record structure to update

bool $finalizeZone

Bump the serial and rectify; a batch caller does that once itself

array|null $comment

RRset comment ['content' => string, 'account' => string] to store with the record where the backend keeps them together

Return Value

RecordWriteResult

RecordWriteResult deleteRecord(int|string $rid, bool $finalizeZone = true)

Delete a record by a given record id

Parameters

int|string $rid

Record ID

bool $finalizeZone

Bump the serial and rectify; a batch caller does that once itself

Return Value

RecordWriteResult

void finalizeZone(int $zoneId, bool $bumpSerial = true)

What every single write ends with: bump the serial (unless told not to) and rectify. Batch callers pass finalizeZone=false to the writes and call this once when they are done; one holding a transaction bumps the serial inside it and calls this with bumpSerial=false after the commit, since PowerDNS rectifies from committed rows.

Parameters

int $zoneId
bool $bumpSerial

Return Value

void

static bool deleteRecordZoneTempl(PDO $db, int|string $rid)

Delete record reference to zone template

Parameters

PDO $db

Database connection

int|string $rid

Record ID

Return Value

bool

true on success

static string getZoneComment(PDO $db, int $zone_id)

Get Zone comment

Parameters

PDO $db

Database connection

int $zone_id

Zone ID

Return Value

string

Zone Comment

bool editZoneComment(int $zone_id, string $comment)

Edit the zone comment

This function validates it if correct it inserts it into the database.

Parameters

int $zone_id

Zone ID

string $comment

Comment to set

Return Value

bool

true on success