OutputStrategyInterface.php 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Drupal\Component\Render;
  3. /**
  4. * Provides an output strategy that formats HTML strings for a given context.
  5. *
  6. * Output strategies assist in transforming HTML strings into strings that are
  7. * appropriate for a given context (e.g. plain-text), through performing the
  8. * relevant formatting. No sanitization is applied.
  9. */
  10. interface OutputStrategyInterface {
  11. /**
  12. * Transforms a given HTML string into to a context-appropriate output string.
  13. *
  14. * This transformation consists of performing the formatting appropriate to
  15. * a given output context (e.g., plain-text email subjects, HTML attribute
  16. * values).
  17. *
  18. * @param string|object $string
  19. * An HTML string or an object with a ::__toString() magic method returning
  20. * HTML markup. The source HTML markup is considered ready for output into
  21. * HTML fragments and thus already properly escaped and sanitized.
  22. *
  23. * @return string
  24. * A new string that is formatted according to the output strategy.
  25. */
  26. public static function renderFromHtml($string);
  27. }