RelationExtension.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. declare(strict_types=1);
  3. namespace PhpMyAdmin\Twig;
  4. use PhpMyAdmin\Relation;
  5. use Twig\Extension\AbstractExtension;
  6. use Twig\TwigFunction;
  7. class RelationExtension extends AbstractExtension
  8. {
  9. /**
  10. * Returns a list of functions to add to the existing list.
  11. *
  12. * @return TwigFunction[]
  13. */
  14. public function getFunctions()
  15. {
  16. global $dbi;
  17. $relation = new Relation($dbi);
  18. return [
  19. new TwigFunction(
  20. 'foreign_dropdown',
  21. [
  22. $relation,
  23. 'foreignDropdown',
  24. ],
  25. ['is_safe' => ['html']]
  26. ),
  27. new TwigFunction(
  28. 'get_display_field',
  29. [
  30. $relation,
  31. 'getDisplayField',
  32. ],
  33. ['is_safe' => ['html']]
  34. ),
  35. new TwigFunction(
  36. 'get_foreign_data',
  37. [
  38. $relation,
  39. 'getForeignData',
  40. ]
  41. ),
  42. new TwigFunction(
  43. 'get_tables',
  44. [
  45. $relation,
  46. 'getTables',
  47. ]
  48. ),
  49. new TwigFunction(
  50. 'search_column_in_foreigners',
  51. [
  52. $relation,
  53. 'searchColumnInForeigners',
  54. ]
  55. ),
  56. ];
  57. }
  58. }