PathautoPatternInterface.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. namespace Drupal\pathauto;
  3. use Drupal\Core\Config\Entity\ConfigEntityInterface;
  4. /**
  5. * Provides an interface for defining Pathauto pattern entities.
  6. */
  7. interface PathautoPatternInterface extends ConfigEntityInterface {
  8. /**
  9. * Get the tokenized pattern used during alias generation.
  10. *
  11. * @return string
  12. */
  13. public function getPattern();
  14. /**
  15. * Set the tokenized pattern to use during alias generation.
  16. *
  17. * @param string $pattern
  18. *
  19. * @return $this
  20. */
  21. public function setPattern($pattern);
  22. /**
  23. * Gets the type of this pattern.
  24. *
  25. * @return string
  26. */
  27. public function getType();
  28. /**
  29. * @return \Drupal\pathauto\AliasTypeInterface
  30. */
  31. public function getAliasType();
  32. /**
  33. * Gets the weight of this pattern (compared to other patterns of this type).
  34. *
  35. * @return int
  36. */
  37. public function getWeight();
  38. /**
  39. * Sets the weight of this pattern (compared to other patterns of this type).
  40. *
  41. * @param int $weight
  42. * The weight of the variant.
  43. *
  44. * @return $this
  45. */
  46. public function setWeight($weight);
  47. /**
  48. * Returns the contexts of this pattern.
  49. *
  50. * @return \Drupal\Core\Plugin\Context\ContextInterface[]
  51. */
  52. public function getContexts();
  53. /**
  54. * Returns whether a relationship exists.
  55. *
  56. * @param string $token
  57. * Relationship identifier.
  58. *
  59. * @return bool
  60. * TRUE if the relationship exists, FALSE otherwise.
  61. */
  62. public function hasRelationship($token);
  63. /**
  64. * Adds a relationship.
  65. *
  66. * The relationship will not be changed if it already exists.
  67. *
  68. * @param string $token
  69. * Relationship identifier.
  70. * @param string|null $label
  71. * (optional) A label, will use the label of the referenced context if not
  72. * provided.
  73. *
  74. * @return $this
  75. */
  76. public function addRelationship($token, $label = NULL);
  77. /**
  78. * Replaces a relationship.
  79. *
  80. * Only already existing relationships are updated.
  81. *
  82. * @param string $token
  83. * Relationship identifier.
  84. * @param string|null $label
  85. * (optional) A label, will use the label of the referenced context if not
  86. * provided.
  87. *
  88. * @return $this
  89. */
  90. public function replaceRelationship($token, $label);
  91. /**
  92. * Removes a relationship.
  93. *
  94. * @param string $token
  95. * Relationship identifier.
  96. *
  97. * @return $this
  98. */
  99. public function removeRelationship($token);
  100. /**
  101. * Returns a list of relationships.
  102. *
  103. * @return array[]
  104. * Keys are context tokens, and values are arrays with the following keys:
  105. * - label (string|null, optional): The human-readable label of this
  106. * relationship.
  107. */
  108. public function getRelationships();
  109. /**
  110. * Gets the selection condition collection.
  111. *
  112. * @return \Drupal\Core\Condition\ConditionInterface[]|\Drupal\Core\Condition\ConditionPluginCollection
  113. */
  114. public function getSelectionConditions();
  115. /**
  116. * Adds selection criteria.
  117. *
  118. * @param array $configuration
  119. * Configuration of the selection criteria.
  120. *
  121. * @return string
  122. * The condition id of the new criteria.
  123. */
  124. public function addSelectionCondition(array $configuration);
  125. /**
  126. * Gets selection criteria by condition id.
  127. *
  128. * @param string $condition_id
  129. * The id of the condition.
  130. *
  131. * @return \Drupal\Core\Condition\ConditionInterface
  132. */
  133. public function getSelectionCondition($condition_id);
  134. /**
  135. * Removes selection criteria by condition id.
  136. *
  137. * @param string $condition_id
  138. * The id of the condition.
  139. *
  140. * @return $this
  141. */
  142. public function removeSelectionCondition($condition_id);
  143. /**
  144. * Gets the selection logic used by the criteria (ie. "and" or "or").
  145. *
  146. * @return string
  147. * Either "and" or "or"; represents how the selection criteria are combined.
  148. */
  149. public function getSelectionLogic();
  150. /**
  151. * Determines if this pattern can apply a given object.
  152. *
  153. * @param $object
  154. * The object used to determine if this plugin can apply.
  155. *
  156. * @return bool
  157. */
  158. public function applies($object);
  159. }