DomainStorageInterface.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. namespace Drupal\domain;
  3. use Drupal\Core\Config\Entity\ConfigEntityStorageInterface;
  4. /**
  5. * Provides an interface for domain entity storage.
  6. */
  7. interface DomainStorageInterface extends ConfigEntityStorageInterface {
  8. /**
  9. * Gets the default domain object.
  10. *
  11. * @return \Drupal\domain\DomainInterface|null
  12. * The default domain record or NULL.
  13. */
  14. public function loadDefaultDomain();
  15. /**
  16. * Returns the id of the default domain.
  17. *
  18. * @return int|bool
  19. * The id of the default domain or FALSE if none is set.
  20. */
  21. public function loadDefaultId();
  22. /**
  23. * Loads multiple domains and sorts by weight.
  24. *
  25. * @param array $ids
  26. * An optional array of specific ids to load.
  27. *
  28. * @return \Drupal\domain\DomainInterface[]
  29. * An array of domain records.
  30. */
  31. public function loadMultipleSorted(array $ids = NULL);
  32. /**
  33. * Loads a domain record by hostname lookup.
  34. *
  35. * @param string $hostname
  36. * A hostname string, in the format example.com.
  37. *
  38. * @return \Drupal\domain\DomainInterface|null
  39. * The domain record or NULL.
  40. */
  41. public function loadByHostname($hostname);
  42. /**
  43. * Returns the list of domains formatted for a form options list.
  44. *
  45. * @return array
  46. * A weight-sorted array of id => label for use in forms.
  47. */
  48. public function loadOptionsList();
  49. /**
  50. * Sorts domains by weight.
  51. *
  52. * For use by loadMultipleSorted().
  53. *
  54. * @param DomainInterface $a
  55. * The first Domain object to sort.
  56. * @param DomainInterface $b
  57. * The Domain object to compare against.
  58. *
  59. * @return bool
  60. * Wether the first domain weight is greater or not.
  61. */
  62. public function sort(DomainInterface $a, DomainInterface $b);
  63. /**
  64. * Gets the entity field schema for domain records.
  65. *
  66. * @return array
  67. * An array representing the field schema of the object.
  68. */
  69. public function loadSchema();
  70. /**
  71. * Removes www. prefix from a hostname, if set.
  72. *
  73. * @param string $hostname
  74. * A hostname.
  75. *
  76. * @return string
  77. * The cleaned hostname.
  78. */
  79. public function prepareHostname($hostname);
  80. /**
  81. * Gets the hostname of the active request.
  82. *
  83. * @return string
  84. * The hostname string of the current request.
  85. */
  86. public function createHostname();
  87. /**
  88. * Creates a machine-name string from the hostname.
  89. *
  90. * This string is the primary key of the entity.
  91. *
  92. * @param string $hostname
  93. * The hostname of the domain record. If empty, the current request will be
  94. * used.
  95. *
  96. * @return string
  97. * A string containing A-Z, a-z, 0-9, and _ characters.
  98. */
  99. public function createMachineName($hostname = NULL);
  100. /**
  101. * Returns the default http/https scheme for the site.
  102. *
  103. * This function helps us account for variable schemes across environments.
  104. *
  105. * @return string
  106. * A string representation of s scheme (http|https).
  107. */
  108. public function getDefaultScheme();
  109. }