Command.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @package Net_EPP
  4. */
  5. class Net_EPP_Frame_Command extends Net_EPP_Frame {
  6. function __construct($command, $type="") {
  7. $this->type = $type;
  8. $command = strtolower($command);
  9. if (!in_array($command, array('check', 'info', 'create', 'update', 'delete', 'renew', 'transfer', 'poll', 'login', 'logout'))) trigger_error("Invalid argument value '$command' for \$command", E_USER_ERROR);
  10. parent::__construct('command');
  11. $this->command = $this->createElement($command);
  12. $this->body->appendChild($this->command);
  13. if (!empty($this->type)) {
  14. $this->payload = $this->createElementNS(
  15. Net_EPP_ObjectSpec::xmlns($this->type),
  16. $this->type.':'.$command
  17. );
  18. $this->command->appendChild($this->payload);
  19. }
  20. $this->clTRID = $this->createElement('clTRID');
  21. $this->clTRID->appendChild($this->createTextNode(''));
  22. $this->body->appendChild($this->clTRID);
  23. }
  24. function addObjectProperty($name, $value=NULL) {
  25. $element = $this->createObjectPropertyElement($name);
  26. $this->payload->appendChild($element);
  27. if ($value instanceof DomNode) {
  28. $element->appendChild($value);
  29. } elseif (isset($value)) {
  30. $element->appendChild($this->createTextNode($value));
  31. }
  32. return $element;
  33. }
  34. function createObjectPropertyElement($name) {
  35. return $this->createElementNS(
  36. Net_EPP_ObjectSpec::xmlns($this->type),
  37. $this->type.':'.$name
  38. );
  39. }
  40. function createExtensionElement($ext, $command) {
  41. $this->extension = $this->createElement('extension');
  42. $this->body->appendChild($this->extension);
  43. $this->extension->payload = $this->createElementNS(
  44. Net_EPP_ObjectSpec::xmlns($ext),
  45. $ext.':'.$command
  46. );
  47. $this->extension->appendChild($this->extension->payload);
  48. }
  49. }
  50. ?>