MessageExtension.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. namespace PhpMyAdmin\Twig;
  9. use PhpMyAdmin\Message;
  10. use Twig\Extension\AbstractExtension;
  11. use Twig\TwigFunction;
  12. /**
  13. * Class MessageExtension
  14. *
  15. * @package PhpMyAdmin\Twig
  16. */
  17. class MessageExtension extends AbstractExtension
  18. {
  19. /**
  20. * Returns a list of functions to add to the existing list.
  21. *
  22. * @return TwigFunction[]
  23. */
  24. public function getFunctions()
  25. {
  26. return array(
  27. new TwigFunction(
  28. 'Message_notice',
  29. function ($string) {
  30. return Message::notice($string)->getDisplay();
  31. },
  32. array('is_safe' => array('html'))
  33. ),
  34. new TwigFunction(
  35. 'Message_error',
  36. function ($string) {
  37. return Message::error($string)->getDisplay();
  38. },
  39. array('is_safe' => array('html'))
  40. ),
  41. );
  42. }
  43. }