TransformationOverviewController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. declare(strict_types=1);
  3. namespace PhpMyAdmin\Controllers;
  4. use PhpMyAdmin\Response;
  5. use PhpMyAdmin\Template;
  6. use PhpMyAdmin\Transformations;
  7. use function array_keys;
  8. /**
  9. * Lists available transformation plugins
  10. */
  11. class TransformationOverviewController extends AbstractController
  12. {
  13. /** @var Transformations */
  14. private $transformations;
  15. /**
  16. * @param Response $response
  17. * @param Transformations $transformations
  18. */
  19. public function __construct($response, Template $template, $transformations)
  20. {
  21. parent::__construct($response, $template);
  22. $this->transformations = $transformations;
  23. }
  24. public function index(): void
  25. {
  26. $header = $this->response->getHeader();
  27. $header->disableMenuAndConsole();
  28. $types = $this->transformations->getAvailableMimeTypes();
  29. $mimeTypes = [];
  30. foreach ($types['mimetype'] as $mimeType) {
  31. $mimeTypes[] = [
  32. 'name' => $mimeType,
  33. 'is_empty' => isset($types['empty_mimetype'][$mimeType]),
  34. ];
  35. }
  36. $transformations = [
  37. 'transformation' => [],
  38. 'input_transformation' => [],
  39. ];
  40. foreach (array_keys($transformations) as $type) {
  41. foreach ($types[$type] as $key => $transformation) {
  42. $transformations[$type][] = [
  43. 'name' => $transformation,
  44. 'description' => $this->transformations->getDescription(
  45. $types[$type . '_file'][$key]
  46. ),
  47. ];
  48. }
  49. }
  50. $this->render('transformation_overview', [
  51. 'mime_types' => $mimeTypes,
  52. 'transformations' => $transformations,
  53. ]);
  54. }
  55. }