MessageExtension.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * hold PhpMyAdmin\Twig\MessageExtension class
  5. *
  6. * @package PhpMyAdmin\Twig
  7. */
  8. declare(strict_types=1);
  9. namespace PhpMyAdmin\Twig;
  10. use PhpMyAdmin\Message;
  11. use Twig\Extension\AbstractExtension;
  12. use Twig\TwigFilter;
  13. /**
  14. * Class MessageExtension
  15. *
  16. * @package PhpMyAdmin\Twig
  17. */
  18. class MessageExtension extends AbstractExtension
  19. {
  20. /**
  21. * Returns a list of filters to add to the existing list.
  22. *
  23. * @return TwigFilter[]
  24. */
  25. public function getFilters()
  26. {
  27. return [
  28. new TwigFilter(
  29. 'notice',
  30. function (string $string) {
  31. return Message::notice($string)->getDisplay();
  32. },
  33. ['is_safe' => ['html']]
  34. ),
  35. new TwigFilter(
  36. 'error',
  37. function (string $string) {
  38. return Message::error($string)->getDisplay();
  39. },
  40. ['is_safe' => ['html']]
  41. ),
  42. new TwigFilter(
  43. 'raw_success',
  44. function (string $string) {
  45. return Message::rawSuccess($string)->getDisplay();
  46. },
  47. ['is_safe' => ['html']]
  48. ),
  49. ];
  50. }
  51. }