class ZoneTemplateWriteService (View source)

Creating, editing and deleting zone templates, saving a zone as a template, and the system-wide default template. Writes report their outcome instead of flashing it.

Methods

__construct(ZoneTemplateRepositoryInterface $repository, ZoneTemplateAccessPolicy $access, ConfigurationInterface $config, LoggerInterface $logger, ZoneTemplatePlaceholders $placeholders)

No description

int|null
getDefaultTemplateId()

Resolve the system-wide default zone template

setDefaultTemplate(int $zone_templ_id)

Mark a template as the system-wide default. Clears is_default from all other templates so only one is flagged at a time. Personal templates (owner != 0) cannot be marked default.

unsetDefaultTemplate()

Clear the system-wide default zone template flag.

addZoneTempl(array $details, int $userid, array $groupIds = [])

Add a zone template

editZoneTempl(array $details, int $zone_templ_id, int $user_id)

Modify zone template

deleteZoneTempl(int $zone_templ_id)

Delete a zone template

addZoneTemplSaveAs(string $template_name, string $description, int $userid, array $records, array $options, string $domain = '')

Add a zone template from zone / another template

Details

__construct(ZoneTemplateRepositoryInterface $repository, ZoneTemplateAccessPolicy $access, ConfigurationInterface $config, LoggerInterface $logger, ZoneTemplatePlaceholders $placeholders)

No description

Parameters

ZoneTemplateRepositoryInterface $repository
ZoneTemplateAccessPolicy $access
ConfigurationInterface $config
LoggerInterface $logger
ZoneTemplatePlaceholders $placeholders

int|null getDefaultTemplateId()

Resolve the system-wide default zone template

Resolution order:

  1. The template with is_default = 1 (global only, owner = 0)
  2. The dns.default_zone_template config setting (id or name)
  3. null (no default; the form falls back to "none")

Names that resolve to multiple templates cause the config setting to be skipped with a warning logged - operators must use the id or rename one of the duplicates.

Return Value

int|null

Template id, or null if no default is configured

ZoneTemplateWriteResult setDefaultTemplate(int $zone_templ_id)

Mark a template as the system-wide default. Clears is_default from all other templates so only one is flagged at a time. Personal templates (owner != 0) cannot be marked default.

Parameters

int $zone_templ_id

Return Value

ZoneTemplateWriteResult

ZoneTemplateWriteResult unsetDefaultTemplate()

Clear the system-wide default zone template flag.

ZoneTemplateWriteResult addZoneTempl(array $details, int $userid, array $groupIds = [])

Add a zone template

Parameters

array $details

zone template details

int $userid

User ID that owns template

array $groupIds

Groups to share it with, as ZoneTemplateGroupShares::groupsForNewTemplate() accepted them

Return Value

ZoneTemplateWriteResult

ZoneTemplateWriteResult editZoneTempl(array $details, int $zone_templ_id, int $user_id)

Modify zone template

Parameters

array $details

array of new zone template details

int $zone_templ_id

zone template id

int $user_id

User ID that is editing the template

Return Value

ZoneTemplateWriteResult

ZoneTemplateWriteResult deleteZoneTempl(int $zone_templ_id)

Delete a zone template

Parameters

int $zone_templ_id

Return Value

ZoneTemplateWriteResult

ZoneTemplateWriteResult addZoneTemplSaveAs(string $template_name, string $description, int $userid, array $records, array $options, string $domain = '')

Add a zone template from zone / another template

Parameters

string $template_name

template name

string $description description
int $userid

user id

array $records

array of zone records

array $options
string $domain

domain to substitute with '[ZONE]' (optional)

Return Value

ZoneTemplateWriteResult

Success carries a warning naming the record types left out