AliasCleanerInterface.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace Drupal\pathauto;
  3. /**
  4. * @todo add class comment.
  5. */
  6. interface AliasCleanerInterface {
  7. /**
  8. * Clean up an URL alias.
  9. *
  10. * Performs the following alterations:
  11. * - Trim duplicate, leading, and trailing back-slashes.
  12. * - Trim duplicate, leading, and trailing separators.
  13. * - Shorten to a desired length and logical position based on word boundaries.
  14. *
  15. * @param string $alias
  16. * A string with the URL alias to clean up.
  17. *
  18. * @return string
  19. * The cleaned URL alias.
  20. */
  21. public function cleanAlias($alias);
  22. /**
  23. * Trims duplicate, leading, and trailing separators from a string.
  24. *
  25. * @param string $string
  26. * The string to clean path separators from.
  27. * @param string $separator
  28. * The path separator to use when cleaning.
  29. *
  30. * @return string
  31. * The cleaned version of the string.
  32. *
  33. * @see pathauto_cleanstring()
  34. * @see pathauto_clean_alias()
  35. */
  36. public function getCleanSeparators($string, $separator = NULL);
  37. /**
  38. * Clean up a string segment to be used in an URL alias.
  39. *
  40. * Performs the following possible alterations:
  41. * - Remove all HTML tags.
  42. * - Process the string through the transliteration module.
  43. * - Replace or remove punctuation with the separator character.
  44. * - Remove back-slashes.
  45. * - Replace non-ascii and non-numeric characters with the separator.
  46. * - Remove common words.
  47. * - Replace whitespace with the separator character.
  48. * - Trim duplicate, leading, and trailing separators.
  49. * - Convert to lower-case.
  50. * - Shorten to a desired length and logical position based on word boundaries.
  51. *
  52. * This function should *not* be called on URL alias or path strings
  53. * because it is assumed that they are already clean.
  54. *
  55. * @param string $string
  56. * A string to clean.
  57. * @param array $options
  58. * (optional) A keyed array of settings and flags to control the Pathauto
  59. * clean string replacement process. Supported options are:
  60. * - langcode: A language code to be used when translating strings.
  61. *
  62. * @return string
  63. * The cleaned string.
  64. */
  65. public function cleanString($string, array $options = array());
  66. /**
  67. * Return an array of arrays for punctuation values.
  68. *
  69. * Returns an array of arrays for punctuation values keyed by a name, including
  70. * the value and a textual description.
  71. * Can and should be expanded to include "all" non text punctuation values.
  72. *
  73. * @return array
  74. * An array of arrays for punctuation values keyed by a name, including the
  75. * value and a textual description.
  76. */
  77. public function getPunctuationCharacters();
  78. /**
  79. * Clean tokens so they are URL friendly.
  80. *
  81. * @param array $replacements
  82. * An array of token replacements
  83. * that need to be "cleaned" for use in the URL.
  84. * @param array $data
  85. * An array of objects used to generate the replacements.
  86. * @param array $options
  87. * An array of options used to generate the replacements.
  88. */
  89. public function cleanTokenValues(&$replacements, $data = array(), $options = array());
  90. /**
  91. * Resets internal caches.
  92. */
  93. public function resetCaches();
  94. }