TXTAdapter.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace MGModule\DNSManager2\mgLibs\custom\dns\submodules\OpenProvider\Adapters;
  3. use MGModule\DNSManager2\mgLibs\custom\dns\record\Record;
  4. use MGModule\DNSManager2\mgLibs\custom\dns\submodules\OpenProvider\OPRecordAdapterType;
  5. class TXTAdapter extends Record
  6. {
  7. /**
  8. * TXTAdapter constructor.
  9. * @param Record $record
  10. */
  11. public function __construct( Record $record)
  12. {
  13. $this->line = $record->line;
  14. $this->name = $record->name;
  15. $this->type = 'TXT';
  16. $this->class = $record->class;
  17. $this->ttl = $record->ttl;
  18. $this->rdlength = $record->rdlength;
  19. $this->rdata = new OPRecordAdapterType();
  20. $this->rdata->txtdata = str_replace('"', "", htmlspecialchars_decode($record->rdata->txtdata));
  21. $this->absoluteName = $record->absoluteName;
  22. $this->customData = $record->customData;
  23. }
  24. public function toDnsManagerRecord($record)
  25. {
  26. $templateData = [
  27. 'name' => $record['name'],
  28. 'type' => $record['type'],
  29. 'ttl' => $record['ttl'],
  30. 'txtdata' => str_replace('"', "", $record['value']),
  31. ];
  32. return Record::tryToCreateFromArray($templateData);
  33. }
  34. }