DomainNegotiatorInterface.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace Drupal\domain;
  3. /**
  4. * Handles the negotiation of the active domain record.
  5. */
  6. interface DomainNegotiatorInterface {
  7. /**
  8. * Determines the active domain request.
  9. *
  10. * The negotiator is passed an httpHost value, which is checked against domain
  11. * records for a match.
  12. *
  13. * @param string $httpHost
  14. * A string representing the hostname of the request (e.g. example.com).
  15. * @param bool $reset
  16. * Indicates whether to reset the internal cache.
  17. */
  18. public function setRequestDomain($httpHost, $reset = FALSE);
  19. /**
  20. * Sets the active domain.
  21. *
  22. * @param \Drupal\domain\DomainInterface $domain
  23. * Sets the domain record as active for the duration of that request.
  24. */
  25. public function setActiveDomain(DomainInterface $domain);
  26. /**
  27. * Stores the inbound httpHost request.
  28. *
  29. * @param string $httpHost
  30. * A string representing the hostname of the request (e.g. example.com).
  31. */
  32. public function setHttpHost($httpHost);
  33. /**
  34. * Gets the inbound httpHost request.
  35. *
  36. * @return string
  37. * A string representing the hostname of the request (e.g. example.com).
  38. */
  39. public function getHttpHost();
  40. /**
  41. * Gets the id of the active domain.
  42. *
  43. * @return string
  44. * The id of the active domain.
  45. */
  46. public function getActiveId();
  47. /**
  48. * Sets the hostname of the active request.
  49. *
  50. * This method is an internal method for use by the public getActiveDomain()
  51. * call. It is responsible for determining the active hostname of the request
  52. * and then passing that data to the negotiator.
  53. *
  54. * @return string
  55. * The hostname, without the "www" if applicable.
  56. */
  57. public function negotiateActiveHostname();
  58. /**
  59. * Gets the active domain.
  60. *
  61. * This method should be called by external classes using the negotiator
  62. * service.
  63. *
  64. * @param bool $reset
  65. * Reset the internal cache of the active domain.
  66. *
  67. * @return \Drupal\domain\DomainInterface
  68. * The active domain object.
  69. */
  70. public function getActiveDomain($reset = FALSE);
  71. /**
  72. * Checks that a URL's hostname is registered as a valid domain or alias.
  73. *
  74. * @param string $hostname
  75. * A string representing the hostname of the request (e.g. example.com).
  76. *
  77. * @return bool
  78. * TRUE if a URL's hostname is registered as a valid domain or alias, or
  79. * FALSE.
  80. */
  81. public function isRegisteredDomain($hostname);
  82. }