View.php 667 B

123456789101112131415161718192021222324
  1. <?php
  2. function viewError($name, $content, $type) {
  3. return "<div class='alert alert-" . $type . "'> <a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a>" . "<strong>" . $name . "</strong> " . $content . "</div>";
  4. }
  5. $function = new Twig_SimpleFunction('makeError', 'viewError');
  6. $twig->addFunction($function);
  7. $twig->addFunction(
  8. new \Twig_SimpleFunction(
  9. 'form_token',
  10. function($lock_to = null) {
  11. static $csrf;
  12. if ($csrf === null) {
  13. $csrf = new AntiCSRF;
  14. }
  15. return $csrf->insertToken($lock_to, false);
  16. },
  17. ['is_safe' => ['html']]
  18. )
  19. );