RelationExtension.php 1.6 KB

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