Guest User

Untitled

a guest
Aug 25th, 2019
79
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function sendForm(Form $form): void
  2. {
  3. $data = $form->jsonSerialize();
  4. switch ($data["type"] ?? ""){
  5. case "custom_form":
  6. if(substr($data["title"] ?? "", 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  7. $data["title"] = $this->translateMessage($data["title"]);
  8. }
  9. foreach ($data["content"] ?? [] as $content){
  10. switch ($content["type"] ?? ""){
  11. case "label":
  12. case "toggle":
  13. case "slider":
  14. case "step_slider":
  15. if(substr($content["text"] ?? "", 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  16. $content["text"] = $this->translateMessage($content["text"]);
  17. }
  18. break;
  19. case "dropdown":
  20. if(substr($content["text"] ?? "", 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  21. $content["text"] = $this->translateMessage($content["text"]);
  22. }
  23. $options = [];
  24. foreach ($content["options"] ?? [] as $option){
  25. if(substr($option, 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  26. $options[] = $this->translateMessage($option);
  27. }
  28. }
  29. $content["options"] = $options;
  30. case "input":
  31. if(substr($content["text"] ?? "", 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  32. $content["text"] = $this->translateMessage($content["text"]);
  33. }
  34. if(substr($content["placeholder"] ?? "", 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  35. $content["placeholder"] = $this->translateMessage($content["placeholder"]);
  36. }
  37. if(substr($content["default"] ?? "", 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  38. $content["default"] = $this->translateMessage($content["default"]);
  39. }
  40. break;
  41. }
  42. // options
  43. }
  44. break;
  45. case "form":
  46. if(substr($data["title"] ?? "", 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  47. $data["title"] = $this->translateMessage($data["title"]);
  48. }
  49. if(substr($data["content"] ?? "", 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  50. $data["content"] = $this->translateMessage($data["content"]);
  51. }
  52. foreach ($data["buttons"] ?? [] as $button){
  53. if(substr($button["text"] ?? "", 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  54. $button["text"] = $this->translateMessage($button["text"]);
  55. }
  56. }
  57. break;
  58. case "modal":
  59. if(substr($data["title"] ?? "", 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  60. $data["title"] = $this->translateMessage($data["title"]);
  61. }
  62. if(substr($data["content"] ?? "", 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  63. $data["content"] = $this->translateMessage($data["content"]);
  64. }
  65. if(substr($data["button1"] ?? "", 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  66. $data["button1"] = $this->translateMessage($data["button1"]);
  67. }
  68. if(substr($data["button2"] ?? "", 0) === LanguageManager::TRANSLATION_IDENTIFIER){
  69. $data["button2"] = $this->translateMessage($data["button2"]);
  70. }
  71. break;
  72. }
  73. parent::sendForm($form);
  74. }
RAW Paste Data