DomainInterface.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <?php
  2. namespace Drupal\domain;
  3. use Drupal\Core\Config\Entity\ConfigEntityInterface;
  4. /**
  5. * Provides an interface defining a domain entity.
  6. */
  7. interface DomainInterface extends ConfigEntityInterface {
  8. /**
  9. * Detects if the current domain is the active domain.
  10. *
  11. * @return bool
  12. * TRUE if domain enabled, FALSE otherwise.
  13. */
  14. public function isActive();
  15. /**
  16. * Detects if the current domain is the default domain.
  17. *
  18. * @return bool
  19. * TRUE if domain set as default, FALSE otherwise.
  20. */
  21. public function isDefault();
  22. /**
  23. * Detects if the domain uses https for links.
  24. *
  25. * @return bool
  26. * TRUE if domain protocol is HTTPS, FALSE otherwise.
  27. */
  28. public function isHttps();
  29. /**
  30. * Makes a domain record the default.
  31. */
  32. public function saveDefault();
  33. /**
  34. * Saves a specific domain attribute.
  35. *
  36. * @param string $name
  37. * The property key to save for the $domain object.
  38. * @param mixed $value
  39. * The value to set for the property.
  40. */
  41. public function saveProperty($name, $value);
  42. /**
  43. * Sets the base path to this domain.
  44. */
  45. public function setPath();
  46. /**
  47. * Sets the domain-specific link to the current URL.
  48. */
  49. public function setUrl();
  50. /**
  51. * Gets the path for a domain.
  52. *
  53. * @return string
  54. * A URL string for the base path to the domain. (e.g. http://example.com/)
  55. */
  56. public function getPath();
  57. /**
  58. * Gets the url for a domain.
  59. *
  60. * @return string
  61. * A URL string for the current request on the requested domain. If the
  62. * current request is /user the return would be http://example.com/user or
  63. * http://one.example.com, depending on the current domain context.
  64. */
  65. public function getUrl();
  66. /**
  67. * Returns the active scheme for a domain record.
  68. *
  69. * This method is to be used when generating URLs.
  70. *
  71. * @param bool $add_suffix
  72. * Tells the method to return :// after the string.
  73. *
  74. * @return string
  75. * Returns a valid scheme (http or https), with or without the suffix.
  76. */
  77. public function getScheme($add_suffix = TRUE);
  78. /**
  79. * Returns the stored scheme value for a domain record.
  80. *
  81. * This method is to be used with forms and when saving domain records. It
  82. * returns the raw value (http|https|variable) of the domain's default scheme.
  83. *
  84. * @return string
  85. * Returns a stored scheme default (http|https|variable) for the record.
  86. */
  87. public function getRawScheme();
  88. /**
  89. * Retrieves the value of the response test.
  90. *
  91. * @return int
  92. * The HTTP response code of the domain test, expected to be 200.
  93. */
  94. public function getResponse();
  95. /**
  96. * Sets the value of the response test.
  97. *
  98. * @param int $response
  99. * The HTTP response code to set.
  100. */
  101. public function setResponse($response);
  102. /**
  103. * Adds a property to the domain record.
  104. *
  105. * @param string $name
  106. * The name of the property to retrieve.
  107. * @param mixed $value
  108. * The value of the property.
  109. */
  110. public function addProperty($name, $value);
  111. /**
  112. * Returns a URL object for a domain.
  113. *
  114. * @param bool $current_path
  115. * Indicates that the link should point to the path of the current request.
  116. *
  117. * @return \Drupal\Core\Url
  118. * A core URL object.
  119. */
  120. public function getLink($current_path = TRUE);
  121. /**
  122. * Returns the redirect status of the current domain.
  123. *
  124. * @return int|null
  125. * If numeric, the type of redirect to issue (301 or 302).
  126. */
  127. public function getRedirect();
  128. /**
  129. * Sets a redirect on the current domain.
  130. *
  131. * @param int $code
  132. * A valid HTTP redirect code (301 or 302).
  133. */
  134. public function setRedirect($code = 302);
  135. /**
  136. * Gets the hostname of the domain.
  137. *
  138. * @return string
  139. * The domain hostname.
  140. */
  141. public function getHostname();
  142. /**
  143. * Sets the hostname of the domain.
  144. *
  145. * @param string $hostname
  146. * The hostname value to set, in the format example.com.
  147. */
  148. public function setHostname($hostname);
  149. /**
  150. * Gets the numeric id of the domain record.
  151. *
  152. * @return int
  153. * The domain id.
  154. */
  155. public function getDomainId();
  156. /**
  157. * Gets the sort weight of the domain record.
  158. *
  159. * @return int
  160. * The domain record sort weight.
  161. */
  162. public function getWeight();
  163. /**
  164. * Sets the type of record match returned by the negotiator.
  165. *
  166. * @param int $match_type
  167. * A numeric constant indicating the type of match derived by the caller.
  168. * Use this value to determine if the request needs to be overridden. Valid
  169. * types are DomainNegotiator::DOMAIN_MATCH_NONE,
  170. * DomainNegotiator::DOMAIN_MATCH_EXACT,
  171. * DomainNegotiator::DOMAIN_MATCH_ALIAS.
  172. */
  173. public function setMatchType($match_type = DomainNegotiator::DOMAIN_MATCH_EXACT);
  174. /**
  175. * Gets the type of record match returned by the negotiator.
  176. *
  177. * This value will be set by the domain negotiation routine and is not present
  178. * when loading a domain record via DomainStorageInterface.
  179. *
  180. * @return int
  181. * The domain record match type.
  182. *
  183. * @see setMatchType()
  184. */
  185. public function getMatchType();
  186. /**
  187. * Find the port used for the domain.
  188. *
  189. * @return string
  190. * An optional port string (e.g. ':8080') or an empty string;
  191. */
  192. public function getPort();
  193. /**
  194. * Creates a unique domain id for this record.
  195. */
  196. public function createDomainId();
  197. /**
  198. * Retrieves the canonical (registered) hostname for the domain.
  199. *
  200. * @return string
  201. * A hostname string.
  202. */
  203. public function getCanonical();
  204. /**
  205. * Sets the canonical (registered) hostname for the domain.
  206. */
  207. public function setCanonical($hostname = NULL);
  208. }